Sohbet Tamamlamaları
POST /v1/chat/completions isteği ve yanıtı.
Sohbet Tamamlamaları
İstek
POST https://apimaster.ai/v1/chat/completions
Başlıklar
| Başlık | Gerekli | Notlar |
|---|---|---|
Authorization |
Evet | Bearer YOUR_API_KEY |
Content-Type |
Evet | application/json |
Gövde (ortak alanlar)
| Alan | Tür | Notlar |
|---|---|---|
model |
metin | ör. claude-sonnet-4-6 |
messages |
dizi | {role, content} |
max_tokens |
sayı | Maksimum tamamlama token sayısı |
temperature |
sayı | İsteğe bağlı |
stream |
mantıksal | SSE akışı |
Örnek
curl -s "https://apimaster.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{"role": "system", "content": "You are helpful."},
{"role": "user", "content": "Say hi in one word."}
],
"max_tokens": 64
}'
Akışsız yanıt
{
"id": "chatcmpl-...",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "..." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 5,
"total_tokens": 15
}
}
Akış
"stream": true ile, gövde text/event-stream biçimindedir; satırlar data: {json} şeklindedir ve data: [DONE] ile sonlanır.
Durum kodları
| Kod | Anlam |
|---|---|
| 400 | Geçersiz parametreler |
| 401 | Kimlik doğrulama başarısız |
| 402 / 403 | Kota veya izin |
| 429 | Hız sınırlaması |
| 502 / 503 | Yukarı akış hatası — tekrar deneyin. |