Skip to content

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

ParameterTypeRequiredDescription
modelstringyesModel name, e.g. gemini-2.5-pro or gemini-2.5-flash-search
messagesarrayyesOpenAI-style message array; content may include sub-items (text/file/url)
temperaturenumbernoSampling temperature (0-2)
top_pnumbernoNucleus sampling threshold
max_tokensnumbernoMax generated tokens
streambooleannoWhether to stream responses
toolsarraynoTool definitions for function calling, OpenAI-compatible
extra_body / thinking_configobjectnoAdvanced options (thinking control, budget, etc.)
response_formatobjectnoStructured 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 }
}