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 requireanthropic-version) - Google:
x-goog-api-key: sk-xxx
Request example
Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | yes | Model name, e.g. gpt-4o |
| messages | array<object> | yes | Chat message array, items like `{ role: 'system' |
| temperature | number | no | Sampling temperature (0-2); higher -> more random |
| top_p | number | no | Nucleus sampling probability threshold (0-1) |
| stream | boolean | no | Use streaming output |
| max_tokens | number | no | Max number of generated tokens |
| n | number | no | Number of candidate completions to generate |
| presence_penalty | number | no | Penalty for introducing new topics (-2.0 ~ 2.0) |
| frequency_penalty | number | no | Penalty to reduce repetition (-2.0 ~ 2.0) |
| logit_bias | object | no | Logit bias map, e.g. { "50256": -100 } |
| user | string | no | End-user identifier for abuse monitoring |
| stop | string or array | no | Stop on any of the provided stop tokens |
| response_format | object | no | Structured 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"
}