POST
/
v1beta
/
models
/
{model}
:generateContent
curl -X POST "https://api.example.com/v1beta/models/gemini-2.5-pro:generateContent?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "What is in this image?"
          },
          {
            "inline_data": {
              "mime_type": "image/jpeg",
              "data": "BASE64_ENCODED_IMAGE_DATA"
            }
          }
        ]
      }
    ]
  }'
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "This image shows a beautiful sunset over the ocean with vibrant orange and pink colors in the sky."
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ]
}
Official documentation: https://ai.google.dev/gemini-api/docs/image-understanding
Analyze and understand images using Google Gemini models. The model can describe images, answer questions about them, and extract information from visual content.

Request Parameters

key
string
required
API key.
contents
array
required
Content array containing text and image data.Each content object contains:
  • role (string): Role (user or model)
  • parts (array): Content parts array, can include:
    • text (string): Text prompt
    • inline_data (object): Image data
      • mime_type (string): Image MIME type (e.g., “image/jpeg”, “image/png”)
      • data (string): Base64-encoded image data
generationConfig
object
Generation configuration.
  • temperature (number): Sampling temperature
  • topP (number): Nucleus sampling parameter
  • maxOutputTokens (integer): Maximum output tokens

Response

Returns analysis and description of the provided image.
curl -X POST "https://api.example.com/v1beta/models/gemini-2.5-pro:generateContent?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "What is in this image?"
          },
          {
            "inline_data": {
              "mime_type": "image/jpeg",
              "data": "BASE64_ENCODED_IMAGE_DATA"
            }
          }
        ]
      }
    ]
  }'
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "This image shows a beautiful sunset over the ocean with vibrant orange and pink colors in the sky."
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ]
}