Chat Completions
LLMTR gateway, OpenAI Chat Completions API’sine uyumludur. Tüm istekler https://llmtr.com/v1/chat/completions adresine POST edilir.
Request
Section titled “Request”POST /v1/chat/completionsAuthorization: Bearer sk_your_keyContent-Type: application/jsonGövde parametreleri
Section titled “Gövde parametreleri”| Alan | Tip | Zorunlu | Açıklama |
|---|---|---|---|
model | string | evet | Canonical model ID (örn. openai/gpt-4o) |
messages | array | evet | OpenAI messages formatı |
stream | boolean | hayır | true ise SSE akışı döner |
temperature | number | hayır | 0-2 aralığında, default model’e göre değişir |
max_tokens | integer | hayır | Çıktı token üst sınırı |
top_p | number | hayır | Nucleus sampling |
frequency_penalty | number | hayır | -2 ile 2 arası |
presence_penalty | number | hayır | -2 ile 2 arası |
stop | string/array | hayır | Durdurma dizileri |
response_format | object | hayır | { "type": "json_object" } destekleyen modellerde |
tools | array | hayır | Function calling (destekleyen modellerde) |
tool_choice | string/object | hayır | auto, none veya belirli tool |
Temel örnek
Section titled “Temel örnek”curl https://llmtr.com/v1/chat/completions \ -H "Authorization: Bearer sk_your_key" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-4o", "messages": [ {"role": "system", "content": "You are a concise assistant."}, {"role": "user", "content": "What is LLMTR?"} ], "temperature": 0.3, "max_tokens": 200 }'Response
Section titled “Response”Başarılı yanıt OpenAI formatıyla birebir aynıdır:
{ "id": "chatcmpl-xxx", "object": "chat.completion", "created": 1739200000, "model": "openai/gpt-4o", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "LLMTR is a unified gateway..." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 24, "completion_tokens": 52, "total_tokens": 76 }}Model kimliği formatı
Section titled “Model kimliği formatı”Tüm modeller canonical olarak provider/model şeklinde referanslanır:
openai/gpt-4oanthropic/claude-sonnet-4.5google/gemini-2.5-flashdeepseek/deepseek-v4-flashmistral/mistral-large-latest
Tüm katalog için dashboard model listesini veya /api/models endpoint’ini kullanın.
Sağlayıcıya özgü davranışlar
Section titled “Sağlayıcıya özgü davranışlar”Bazı sağlayıcılar ek body alanları veya özel seçenekler destekler. Desteklenen alanları doğrudan isteğinize ekleyebilirsiniz.
Xiaomi MiMo
Section titled “Xiaomi MiMo”mimo/mimo-v2-pro, mimo/mimo-v2-omni, mimo/mimo-v2-flash modelleri.
Web aramasını etkinleştirme. İki yöntem de kullanılabilir:
// Yöntem 1: Tool alanı ile{ "tools": [{ "type": "web_search" }] }
// Yöntem 2: Body alanı ile{ "webSearchEnabled": true }Web araması kullanılan isteklerde ek sağlayıcı ücretleri oluşabilir. Üretim trafiği göndermeden önce ilgili modelin fiyatını kontrol edin.
Thinking kontrolü. Destekleyen modellerde body alanına thinking ekleyerek davranışı ayarlayabilirsiniz:
{ "thinking": { "type": "enabled" } } // veya "disabled"Hata kodları
Section titled “Hata kodları”| HTTP | error.type | Anlamı |
|---|---|---|
| 400 | invalid_request_error | Geçersiz parametre / eksik alan |
| 401 | auth_error | Geçersiz veya süresi dolmuş API anahtarı |
| 403 | forbidden | Bu model için yetki yok |
| 429 | rate_limit_exceeded | Rate limit aşıldı |
| 500 | internal_error | Gateway iç hatası |
| 502 | provider_error | Sağlayıcı tarafında hata |
Detay için Hatalar bölümüne bakın.