Overview
This endpoint provides file analysis functionality (no stream).
Authentication
This endpoint requires authentication using a Bearer token.
Authorization
string
default:"sk-***********"
required
Your API key in the format: sk-***********
Path Parameters
model
string
default:"gemini-2.0-flash"
required
The model to use for the file analysis. Available models: gemini-2.0-flash, etc.
Request Body Parameters
An array of content objects representing the conversation history and file data.Show Content Object Structure
The role of the message sender. Typically "user" or "model". Optional for single-turn requests.
An array of parts that make up the message content. Can include both text and file data.Show Parts Object Structure
Text content of the message or prompt for analyzing the file.
Reference to file data for analysis (PDF, images, etc.).
The MIME type of the file (e.g., "application/pdf", "image/jpeg", "image/png").
The URI of the file to analyze. Can be a public URL.
Request Example
curl --location 'https://gptproto.com/v1beta/models/gemini-2.0-flash: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"
}
}
]
}
]
}'
Response
Successful response containing file analysis results{
"candidates": [
{
"content": {
"parts": [
{
"text": "这是一份名为《Essential English》的PDF文档。根据文档内容分析,这是一本英语学习教材..."
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 1520,
"candidatesTokenCount": 256,
"totalTokenCount": 1776
}
}
Error Responses
{
"error": {
"message": "Invalid signature",
"type": "401"
}
}