OpenAI Chat Completions
RunAPI'nin OpenAI uyumlu Chat Completions işlemi aracılığıyla bir istek gönderin.
Genel Bakış
RunAPI'nin OpenAI uyumlu Chat Completions işlemini, uyumlu bir model ve protokolün istek ile yanıt şekilleriyle kullanın.
Hızlı başlangıç
- Bir API anahtarı oluşturun ve RUNAPI_API_KEY olarak ayarlayın.
- Uyumlu bir model seçin, ardından belgelenen yol parametrelerini ve JSON gövdesini gönderin.
- Bu işlem için gösterilen JSON yanıtını veya sunucu tarafından gönderilen olayları okuyun ve protokol hatalarını işleyin.
Uç Nokta
- Temel URL
https://runapi.ai- Sözleşme sürümü
v1- Tercih edilen kimlik doğrulama
Authorization: Bearer YOUR_API_TOKEN
Kimlik doğrulama taşıyıcıları
RunAPI aşağıda listelenen her taşıyıcıyı kabul eder. Oluşturulan örnekler, protokolün tercih ettiği başlığı kullanır.
- header - Tercih edilen
Authorization: Bearer YOUR_API_TOKEN- header
x-api-key: YOUR_API_TOKEN- header
x-goog-api-key: YOUR_API_TOKEN- query
?key=YOUR_API_TOKEN
Uyumlu modeller
Güncel fiyatlandırma, hız sınırları ve ticari kullanım ayrıntıları için bir model sayfası açın.
60 uyumlu modeli göster
- claude-fable-5-1
- claude-fable-5
- claude-sonnet-5
- claude-opus-5
- claude-opus-4-8
- claude-opus-4-7
- claude-opus-4-6
- claude-sonnet-4-6
- claude-opus-4-5-20251101
- claude-sonnet-4-5-20250929
- claude-haiku-4-5-20251001
- claude-opus-4-1-20250805
- gpt-5.5
- gpt-5.5-pro
- gpt-5.4
- gpt-5.4-mini
- gpt-5.4-nano
- gpt-5.4-pro
- gpt-5.3-codex
- gpt-5.3-codex-spark
- gpt-5.2
- gpt-5.6-luna
- gpt-5.6-sol
- gpt-5.6-terra
- gpt-6-astra
- gemini-3.7-flash
- gemini-3.6-flash
- gemini-3.5-flash
- gemini-3.1-pro-preview
- gemini-3-flash-preview
- gemini-2.5-pro
- gemini-2.5-flash
- deepseek-v4-flash-vision-exp
- deepseek-v4-pro
- deepseek-v4-flash
- glm-5.3
- glm-5.2
- glm-5.1
- glm-5-turbo
- glm-5
- glm-4.7
- glm-4.6
- glm-4.5
- glm-4.5-air
- kimi-k3
- kimi-k2.7-code
- kimi-k2.6
- kimi-k2.5
- MiniMax-M3
- MiniMax-M2.7
- MiniMax-M2.7-highspeed
- MiniMax-M2.5
- MiniMax-M2.5-highspeed
- MiniMax-M2.1
- MiniMax-M2
- mimo-v2.5-pro
- mimo-v2.5
- grok-4.20-0309-non-reasoning
- grok-4.5
- grok-4.3
İstek sözleşmesi
Yalnızca hem genel protokol hem de RunAPI destek kanıtı olan alanlar listelenmektedir. Ek JSON gövde alanları doğrudan iletilir.
JSON gövdesi9 alan
max_tokens["integer", "null"]Desteklenen modeller için saklanan uyumluluk üretim token sınırı; model desteği farklılık gösterebilir.
messagesarrayOpenAI Chat Completions biçiminde konuşma iletileri.
messages[].content["string", "array"]messages[].rolestringmodelstringUyumlu model kataloğu tarafından döndürülen RunAPI model tanımlayıcısı.
stream["boolean", "null"]Chat Completions parçalarını sunucu tarafından gönderilen olaylar olarak döndür.
Varsayılan:false
temperature["number", "null"]Örnekleme sıcaklığı; model desteği değişiklik gösterebilir.
toolsarrayModelin çağırabileceği araçlar.
top_p["number", "null"]Çekirdek örnekleme olasılığı; model desteği farklılık gösterebilir.
İstek örneği
{
"messages": [
{
"content": "Summarize one practical improvement for an API deployment.",
"role": "user"
}
],
"model": "gpt-5.4",
"stream": false
}
Eş zamanlı yanıt
Şema
{
"additionalProperties": true,
"properties": {
"choices": {
"type": "array"
},
"created": {
"type": "integer"
},
"id": {
"type": "string"
},
"model": {
"type": "string"
},
"object": {
"const": "chat.completion",
"type": "string"
},
"usage": {
"additionalProperties": true,
"properties": {
"completion_tokens": {
"type": "integer"
},
"prompt_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"prompt_tokens",
"completion_tokens",
"total_tokens"
],
"type": "object"
}
},
"required": [
"id",
"object",
"created",
"model",
"choices"
],
"type": "object"
}
Örnek
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! How can I help today?",
"role": "assistant"
}
}
],
"created": 1785196800,
"id": "chatcmpl_example",
"model": "gpt-5.4",
"object": "chat.completion",
"usage": {
"completion_tokens": 8,
"prompt_tokens": 12,
"total_tokens": 20
}
}
SSE olayı: chunk
Şema
{
"additionalProperties": true,
"properties": {
"choices": {
"type": "array"
},
"created": {
"type": "integer"
},
"id": {
"type": "string"
},
"model": {
"type": "string"
},
"object": {
"const": "chat.completion.chunk",
"type": "string"
},
"usage": {
"oneOf": [
{
"additionalProperties": true,
"properties": {
"completion_tokens": {
"type": "integer"
},
"prompt_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"prompt_tokens",
"completion_tokens",
"total_tokens"
],
"type": "object"
},
{
"type": "null"
}
]
}
},
"required": [
"id",
"object",
"choices"
],
"type": "object"
}
Örnek
{
"choices": [
{
"delta": {
"content": "Hello"
},
"finish_reason": null,
"index": 0
}
],
"id": "chatcmpl_example",
"object": "chat.completion.chunk",
"usage": null
}
Protokol hatası: invalid_request
Şema
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Örnek
{
"error": {
"code": null,
"message": "messages is required",
"param": "messages",
"type": "invalid_request_error"
}
}
Kullanım
Şema
{
"additionalProperties": true,
"properties": {
"completion_tokens": {
"type": "integer"
},
"prompt_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"prompt_tokens",
"completion_tokens",
"total_tokens"
],
"type": "object"
}
Örnek
{
"completion_tokens": 8,
"prompt_tokens": 12,
"total_tokens": 20
}
Oluşturulan Kod Örnekleri
Her cURL, JavaScript ve Python örneği, protokole özgü bir SDK gerektirmeden bu sözleşmedeki doğrulanmış isteği gönderir.
Yükle
pip install requests
import requests
response = requests.post(
"https://runapi.ai/v1/chat/completions",
headers={"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"},
json={"model": "gpt-5.4", "messages": [{"role": "user", "content": "Summarize one practical improvement for an API deployment."}], "stream": False}
)
response.raise_for_status()
print(response.json())