Skip to content

Gemini (native format) — File Analysis

Summary: Gemini native-format requests support mixed file and text inputs via the contents array. This page provides the minimal required fields, example requests, and response examples for calling Gemini native endpoints on this platform (camelCase parameter names).


Overview

  • Method: POST
  • Path: /v1beta/models/{model}:{action} (example: /v1beta/models/gemini-2.5-flash:generateContent)
  • Content-Type: application/json

Authentication

  • Supported authentication methods:
    • Authorization: Bearer sk-xxx (recommended)
    • x-goog-api-key: <api-key> (optional)

Path parameters

ParameterRequiredDescription
modelyesModel name, e.g. gemini-2.5-flash
actionyesAction name, e.g. generateContent (non-stream) or streamGenerateContent?alt=sse (stream)

Request body (structure and notes)

  • Top-level JSON field: contents (required, array). Each element is a content object, typically containing role and parts.

Common request fields:

FieldTypeRequiredDescription
contentsarrayyesArray of request contents; each item contains role and parts
contents[].rolestringyesRole, typically user / system / assistant
contents[].partsarrayyesArray of parts; items are objects that may include text for textual content

Note: Gemini native format supports additional optional fields (thinking controls, extraBody, tools, etc.). The platform standardizes on camelCase parameter names (e.g. toolConfig instead of tool_config).


Examples

Simple text example (curl)

bash
curl -X POST "https://api.gpt.ge/v1beta/models/gemini-2.5-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxx" \
  -d '{
    "contents": [
      { "role": "user", "parts": [{ "text": "Hello, please give a brief self-introduction" }] }
    ]
  }'

File analysis example (curl, file using base64 data URI)

bash
curl -X POST "https://api.gpt.ge/v1beta/models/gemini-2.5-pro:generateContent" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxx" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Please summarize the key points in the attached API document" },
          { "file": { "filename": "api-doc.pdf", "fileData": "data:application/pdf;base64,JVBERi0xLjQKJ..." } }
        ]
      }
    ]
  }'

JavaScript example

javascript
await fetch('https://api.gpt.ge/v1beta/models/gemini-2.5-flash:generateContent', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer sk-xxxx' },
  body: JSON.stringify({ contents: [{ role: 'user', parts: [{ text: 'Hello, please give a brief self-introduction' }] }] })
}).then(r => r.json()).then(console.log)

Python example (requests)

python
import requests

payload = {
  'contents': [
    { 'role': 'user', 'parts': [ { 'text': 'Please summarize this document' } ] }
  ]
}

resp = requests.post('https://api.gpt.ge/v1beta/models/gemini-2.5-flash:generateContent', headers={'Content-Type':'application/json','Authorization':'Bearer sk-xxxx'}, json=payload)
print(resp.json())

Response example (200)

json
{
  "id": "resp-1234",
  "object": "model.response",
  "created": 1725014307,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This is a brief summary of the document: ..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 50, "completion_tokens": 120, "total_tokens": 170 }
}

Server example: https://api.gpt.ge

For more advanced parameters (thinking level, extraBody, tools, etc.), see Gemini's official docs or other example pages in the project.