Gemini (OpenAI format) — File Analysis
Summary: Compatible with OpenAI-style parameters. Supports mixed inputs of text and various file types (PDF/image/audio/video/text) for document parsing, summarization, and QA.
Overview
- Method:
POST - Path:
/v1/chat/completions - Content-Type:
application/json
Supported file types (examples)
- .pdf, .mp3, .mp4, .wav, .png, .jpg, .jpeg, .txt, .mov, .mpeg, .mpg, .avi, .wmv, .flv
Authentication
- Use
Authorization: Bearer sk-xxx(recommended).
Common request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | yes | Model name, e.g. gemini-2.5-pro or gemini-2.5-flash-search |
| messages | array | yes | OpenAI-style message array; content may include sub-items (text/file/url) |
| temperature | number | no | Sampling temperature (0-2) |
| top_p | number | no | Nucleus sampling threshold |
| max_tokens | number | no | Max generated tokens |
| stream | boolean | no | Whether to stream responses |
| tools | array | no | Tool definitions for function calling, OpenAI-compatible |
| extra_body / thinking_config | object | no | Advanced options (thinking control, budget, etc.) |
| response_format | object | no | Structured output definition |
Note: model names with -thinking or thinking-* suffix indicate "thinking" capability and may accept thinking_config.
Examples
Text chat (curl)
bash
curl -X POST "https://api.gpt.ge/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxx" \
-d '{
"model": "gemini-2.5-pro",
"messages": [ { "role": "user", "content": [ { "type": "text", "text": "Hello, who are you?" } ] } ],
"max_tokens": 1688,
"temperature": 0.5,
"stream": false
}'File analysis (curl, base64 data URI)
bash
curl -X POST "https://api.gpt.ge/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxx" \
-d '{
"model": "gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Summarize the document content" },
{ "type": "file", "file": { "filename": "api-doc.pdf", "file_data": "data:application/pdf;base64,JVBERi0xLjQKJ..." } }
]
}
],
"max_tokens": 6000,
"stream": false
}'Tip: For files >20MB prefer file_url or image_url with a network address.
JavaScript example
javascript
fetch('https://api.gpt.ge/v1/chat/completions', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer sk-xxxx' },
body: JSON.stringify({
model: 'gemini-2.5-pro',
messages: [{ role: 'user', content: [{ type: 'text', text: 'Please summarize the attachment' }, { type: 'file', file: { filename: 'doc.pdf', file_data: 'data:application/pdf;base64,JVBERi0x...' } }] }]
})
}).then(r => r.json()).then(console.log)Python example
python
import requests
payload = {
'model': 'gemini-2.5-pro',
'messages': [ { 'role': 'user', 'content': [ { 'type': 'text', 'text': 'Please summarize the attachment' } ] } ]
}
resp = requests.post('https://api.gpt.ge/v1/chat/completions', headers={'Content-Type':'application/json','Authorization':'Bearer sk-xxxx'}, json=payload)
print(resp.json())Response example (200)
json
{
"id": "resp-12345",
"object": "chat.completion",
"created": 1725014307,
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Document highlights:..." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 10, "completion_tokens": 200, "total_tokens": 210 }
}