Skip to main content
POST
/
v1beta
/
models
/
gemini-3-pro-preview:generateContent
gemini-3-pro-preview (image to text)
curl --request POST \
  --url https://api.example.com/v1beta/models/gemini-3-pro-preview:generateContent
Gemini’s official format for the image to text API.
curl --location 'https://gptproto.com/v1beta/models/gemini-3-pro-preview:generateContent' \
--header 'Authorization: Bearer sk-***********' \
--header 'Content-Type: application/json' \
--data '{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "这张图片里有什么?"
                },
                {
                    "inlineData": {
                        "mimeType": "image/jpeg",
                        "data": "${base64Image}"
                    }
                }
            ]
        }
    ],
    "generationConfig": {
        "temperature": 0.3
    },
    "safetySettings": [
        {
            "category": "HARM_CATEGORY_HARASSMENT",
            "threshold": "BLOCK_MEDIUM_AND_ABOVE"
        },
        {
            "category": "HARM_CATEGORY_HATE_SPEECH",
            "threshold": "BLOCK_MEDIUM_AND_ABOVE"
        }
    ]
}'
{
  "error": {
    "code": 401,
    "message": "Invalid API key provided.",
    "status": "UNAUTHENTICATED"
  }
}

Parameters

ParameterTypeRequiredDefaultDescription
contentsarray✅ Yes-Contains the content to be analyzed, including text and image references.
rolestring✅ Yes-The role of the message sender (e.g., “user”).
partsarray✅ Yes-Parts of the content, can include text and image data.
textstring✅ Yes-The text prompt for the image analysis.
inlineDataobject✅ Yes-The inline image data to be analyzed.
mimeTypestring✅ Yes-The MIME type of the image (e.g., “image/jpeg”).
datastring✅ Yes-The base64-encoded image data.
generationConfigobject❌ No-Generation configuration settings.
temperaturenumber❌ No0.3Controls randomness in the response (0.0 to 1.0).
safetySettingsarray❌ No-Safety settings for content filtering.
categorystring✅ Yes-The harm category to filter.
thresholdstring✅ Yes-The threshold for blocking content (e.g., “BLOCK_MEDIUM_AND_ABOVE”).