Skip to main content
POST
/
v1beta
/
models
/
{model}
:generateContent
gemini-2.5-pro (file analysis)
curl --request POST \
  --url https://api.example.com/v1beta/models/{model}:generateContent
Gemini’s official format for the file analysis API.
curl --location 'https://gptproto.com/v1beta/models/gemini-2.5-pro:generateContent' \
--header 'Authorization: sk-***********' \
--header 'Content-Type: application/json' \
--data '{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "帮我分析这份文件"
                },
                {
                    "file_data": {
                        "mime_type": "application/pdf",
                        "file_uri": "https://oss.heyoos.com/ai-draw/material/Essential-English.pdf"
                    }
                }
            ]
        }
    ]
}'
{
  "error": {
    "message": "Input may not meet the guidelines. Please adjust and try again.",
    "type": "503"
  }
}

Path Parameters

Parameters

ParameterTypeRequiredDefaultDescription
contentsarray✅ Yes-An array of content objects representing the conversation history and file data. The role of the message sender. Typically "user" or "model". Optional for single-turn requests.
partsarray✅ Yes-An array of parts that make up the message content. Can include both text and file data. Text content of the message or prompt for analyzing the file.
file_dataobject❌ No-Reference to file data for analysis (PDF, images, etc.). The MIME type of the file (e.g., "application/pdf", "image/jpeg", "image/png").
file_uristring✅ Yes-The URI of the file to analyze. Can be a public URL.