Разделы документации
Chat Completions
POST /v1/chat/completions — основной inference-запрос, streaming и параметры.
OpenAI-compatible chat endpoint. Подходит для агентов, скриптов и IDE.
Запрос
curl https://api.tokendock.cloud/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "user", "content": "Привет!"}
]
}'
POST https://api.tokendock.cloud/v1/chat/completions
Основные поля
| Поле | Обязательно | Описание |
|---|---|---|
model |
да | ID из GET /v1/models или pricing |
messages |
да | Массив {role, content} — system, user, assistant |
stream |
нет | true — ответ SSE по чанкам |
temperature |
нет | 0–2, случайность ответа |
max_tokens |
нет | Лимит токенов ответа |
Streaming
curl https://api.tokendock.cloud/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","stream":true,"messages":[{"role":"user","content":"Привет!"}]}'
Клиент должен обрабатывать text/event-stream.
Ответ (не streaming)
{
"id": "chatcmpl-...",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 20,
"total_tokens": 30
}
}
Ошибки
Неверная модель, ключ или недостаток квоты — см. коды ошибок.
