Skip to content

Chat API (Image Analysis)

Short description: Chat interface that accepts mixed image and text inputs, suitable for image understanding and visual Q&A. Models must support image analysis (e.g., multimodal models like gpt-4o).


Overview

  • Method: POST
  • Path: /v1/chat/completions
  • Content-Type: application/json

Authentication

Supports common header-based authentication formats:

  • OpenAI: Authorization: Bearer sk-xxx
  • Anthropic: x-api-key: sk-xxx (may require anthropic-version)
  • Google: x-goog-api-key: sk-xxx

Request Examples

Body parameters

ParameterTypeRequiredDescription
modelstringyesModel name that supports image analysis, e.g. gpt-4o
messagesarray<object>yesArray of chat messages; each item includes rolecontentcontent can be text or image references
temperaturenumbernoSampling temperature (0-2)
top_pnumbernoNucleus sampling threshold
streambooleannoWhether to stream responses
max_tokensnumbernoMax generated tokens (default example uses 300)
nnumbernoNumber of candidate completions
presence_penaltynumbernoPresence penalty (-2.0 ~ 2.0)
frequency_penaltynumbernoFrequency penalty (-2.0 ~ 2.0)
logit_biasobjectnoLogit bias mapping
userstringnoEnd-user identifier
stopstring or arraynoStop sequence(s)

About content in messages:

  • Text example: { "type": "text", "text": "What is this?" }
  • Image example: { "type": "image_url", "image_url": { "url": "https://example.com/img.jpg" } } Supports data: base64 URLs or network URLs.

curl example

bash
curl -X POST "https://api.gpt.ge/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxx" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role":"user","content":[{"type":"text","text":"What is this?"}]},
      {"role":"user","content":[{"type":"image_url","image_url":{"url":"data:image/jpeg;base64,...(base64 omitted)..."}}]}
    ],
    "max_tokens": 300,
    "temperature": 0.5
  }'

JavaScript (fetch) 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: 'gpt-4o',
    messages: [
      { role: 'user', content: [{ type: 'text', text: 'What is this?' }] },
      { role: 'user', content: [{ type: 'image_url', image_url: { url: 'https://example.com/img.jpg' } }] }
    ],
    max_tokens: 300,
    temperature: 0.5
  })
}).then(r => r.json()).then(console.log)

Python example (requests)

python
import requests

payload = {
  'model': 'gpt-4o',
  'messages': [
    {'role': 'user', 'content': [{'type': 'text', 'text': 'What is this?'}]},
    {'role': 'user', 'content': [{'type': 'image_url', 'image_url': {'url': 'https://example.com/img.jpg'}}]}
  ],
  'max_tokens': 300,
  'temperature': 0.5
}

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": "chatcmpl-A7ETdn5hnbTjpw9dtRifjMFZYcdFW",
  "object": "chat.completion",
  "created": 1726287309,
  "model": "gpt-4o-2024-05-13",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This is a cartoon-style portrait of an elderly man with white hair and a beard, smiling brightly and wearing a blue outfit.",
        "refusal": null
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 265,
    "completion_tokens": 46,
    "total_tokens": 311,
    "completion_tokens_details": { "reasoning_tokens": 0 }
  },
  "system_fingerprint": "fp_992d1ea92d"
}