Skip to content

Chat API (General)

Short description: General chat/conversation API compatible with OpenAI, Claude, Gemini formats.


Overview

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

Authentication

Supports common header-based authentication:

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

Request example

Body parameters

ParameterTypeRequiredDescription
modelstringyesModel name, e.g. gpt-4o
messagesarray<object>yesChat message array, items like `{ role: 'system'
temperaturenumbernoSampling temperature (0-2); higher -> more random
top_pnumbernoNucleus sampling probability threshold (0-1)
streambooleannoUse streaming output
max_tokensnumbernoMax number of generated tokens
nnumbernoNumber of candidate completions to generate
presence_penaltynumbernoPenalty for introducing new topics (-2.0 ~ 2.0)
frequency_penaltynumbernoPenalty to reduce repetition (-2.0 ~ 2.0)
logit_biasobjectnoLogit bias map, e.g. { "50256": -100 }
userstringnoEnd-user identifier for abuse monitoring
stopstring or arraynoStop on any of the provided stop tokens
response_formatobjectnoStructured output configuration (see docs)

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": "Good evening"}],
    "max_tokens": 1688,
    "temperature": 0.5,
    "stream": false
  }'

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: 'Good evening' }],
    max_tokens: 1688,
    temperature: 0.5
  })
}).then(r => r.json()).then(console.log)

Python (requests) example

python
import requests

resp = requests.post(
    'https://api.gpt.ge/v1/chat/completions',
    headers={'Content-Type': 'application/json', 'Authorization': 'Bearer sk-xxxx'},
    json={
        'model': 'gpt-4o',
        'messages': [{'role': 'user', 'content': 'Good evening'}],
        'max_tokens': 1688,
        'temperature': 0.5
    }
)
print(resp.json())

Response example (200)

json
{
  "id": "chatcmpl-A1iMgDLzZtUJ9QDpfqDLxKH0zfUnp",
  "object": "chat.completion",
  "created": 1724972230,
  "model": "gpt-4o-2024-05-13",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Good evening! How can I help you today?",
        "refusal": null
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 10,
    "total_tokens": 19
  },
  "system_fingerprint": "fp_157b3831f5"
}