Skip to main content
POST
CometAPI, Chat Completions isteklerini tek bir OpenAI uyumlu arayüz üzerinden OpenAI, Claude ve Gemini dahil olmak üzere birden çok sağlayıcıya yönlendirir. model parametresini değiştirerek modeller arasında geçiş yapın; çoğu OpenAI uyumlu SDK, base_url değerini https://api.cometapi.com/v1 olarak ayarlayarak çalışır.
İstek parametreleri ve yanıt alanları, model sağlayıcıları arasında önemli ölçüde farklılık gösterebilir. Parametre listesinin tamamına veya sağlayıcıya özgü davranışlara ihtiyaç duyduğunuzda, kullandığınız modelin arkasındaki sağlayıcının resmî belgelerini inceleyin. Örneğin, reasoning_effort yalnızca reasoning modelleri için geçerlidir (o-series, GPT-5.1+) ve bazı modeller logprobs ya da n özelliğini > 1 desteklemez.
OpenAI Pro modelleri, o-series reasoning modelleri ve Codex modelleri için, Responses uç noktasını kullanın. Bu model aileleri, Responses API’de daha kapsamlı desteğe sahiptir.

Mesaj rolleri

Yeni modellerde (GPT-4.1, GPT-5 serisi, o-series), talimat mesajları için system yerine developer tercih edin. Her ikisi de çalışır, ancak developer daha güçlü talimat izleme davranışı sağlar.

Multimodal girdi gönderme

Birçok model, metnin yanı sıra görüntü ve sesi de destekler. Multimodal mesajlar göndermek için content için dizi biçimini kullanın:
detail parametresi, görüntü analizi derinliğini denetler:
  • low — daha hızlıdır, daha az Token kullanır (sabit maliyet)
  • high — ayrıntılı analiz, daha fazla Token tüketilir
  • auto — modele karar verdirir (varsayılan)

Yanıtları Streaming ile alma

Artımlı çıktı almak için stream değerini true olarak ayarlayın. Yanıt şu şekilde iletilir: Server-Sent Events (SSE), burada her olay bir chat.completion.chunk nesnesi içerir:
Streaming yanıtlarına Token kullanım istatistiklerini eklemek için stream_options.include_usage değerini true olarak ayarlayın. Kullanım verileri, [DONE] öncesindeki son parçada görünür.

Yapılandırılmış çıktı isteme

Modeli belirli bir şemayla eşleşen geçerli JSON döndürmeye zorlamak için response_format kullanın:
JSON Schema modu (json_schema), çıktının şemanızla tam olarak eşleşmesini garanti eder. JSON Object modu (json_object) yalnızca geçerli JSON’u garanti eder; yapı zorunlu kılınmaz.

Araçları ve function’ları çağırma

Modelin harici function’ları çağırmasını sağlamak için araç tanımları sağlayın:
Model bir aracı çağırmaya karar verdiğinde, yanıtta finish_reason: "tool_calls" bulunur ve message.tool_calls dizisi function adını ve bağımsız değişkenleri içerir. Ardından function’ı çalıştırır ve sonucu, eşleşen tool_call_id ile bir tool mesajı olarak geri gönderirsiniz.

Sağlayıcılar arası notlar

  • max_tokens — Eski parametre. Çoğu modelle çalışır ancak yeni OpenAI modelleri için kullanım dışıdır.
  • max_completion_tokens — GPT-4.1, GPT-5 serisi ve o-series modelleri için önerilen parametre. Hem çıktı Token’larını hem de reasoning Token’larını içerdiğinden reasoning modelleri için gereklidir.
CometAPI, farklı sağlayıcılara yönlendirme yaparken eşlemeyi otomatik olarak yönetir.
  • system — Geleneksel talimat rolü. Tüm modellerle çalışır.
  • developer — o1 modelleriyle sunulmuştur. Yeni modeller için daha güçlü talimat izleme sağlar. Eski modellerde system davranışına geri döner.
GPT-4.1+ veya o-series modellerini hedefleyen yeni projelerde developer kullanın.

SSS

Hız sınırları nasıl ele alınır?

429 Too Many Requests ile karşılaşıldığında üstel geri çekilme uygulayın:

Konuşma bağlamı nasıl korunur?

Konuşma geçmişinin tamamını messages dizisine ekleyin:

finish_reason neanlamına gelir?

Maliyetler nasıl denetlenir?

  1. Çıktı uzunluğunu sınırlamak için max_completion_tokens kullanın.
  2. Zekâ ve maliyet dengesi için gpt-5.6-terra veya verimli, yüksek hacimli iş yükleri için gpt-5.6-luna kullanın.
  3. Prompt’ları kısa tutun — gereksiz bağlamdan kaçının.
  4. usage yanıt alanındaki Token kullanımını izleyin.

Yetkilendirmeler

Authorization
string
header
gerekli

Bearer token authentication. Use your CometAPI key.

Gövde

application/json
model
string
varsayılan:gpt-5.6-sol
gerekli

Model ID to use for this request. See the Models page for current options.

Örnek:

"gpt-4.1"

messages
object[]
gerekli

A list of messages forming the conversation. Each message has a role (system, user, assistant, or developer) and content (text string or multimodal content array).

stream
boolean

If true, partial response tokens are delivered incrementally via server-sent events (SSE). The stream ends with a data: [DONE] message.

temperature
number
varsayılan:1

Sampling temperature between 0 and 2. Higher values (e.g., 0.8) produce more random output; lower values (e.g., 0.2) make output more focused and deterministic. Recommended to adjust this or top_p, but not both.

Gerekli aralık: 0 <= x <= 2
top_p
number
varsayılan:1

Nucleus sampling parameter. The model considers only the tokens whose cumulative probability reaches top_p. For example, 0.1 means only the top 10% probability tokens are considered. Recommended to adjust this or temperature, but not both.

Gerekli aralık: 0 <= x <= 1
n
integer
varsayılan:1

Number of completion choices to generate for each input message. Defaults to 1.

stop
string

Up to 4 sequences where the API will stop generating further tokens. Can be a string or an array of strings.

max_tokens
integer

Maximum number of tokens to generate in the completion. The total of input + output tokens is capped by the model's context length.

presence_penalty
number
varsayılan:0

Number between -2.0 and 2.0. Positive values penalize tokens based on whether they have already appeared, encouraging the model to explore new topics.

Gerekli aralık: -2 <= x <= 2
frequency_penalty
number
varsayılan:0

Number between -2.0 and 2.0. Positive values penalize tokens proportionally to how often they have appeared, reducing verbatim repetition.

Gerekli aralık: -2 <= x <= 2
logit_bias
object

A JSON object mapping token IDs to bias values from -100 to 100. The bias is added to the model's logits before sampling. Values between -1 and 1 subtly adjust likelihood; -100 or 100 effectively ban or force selection of a token.

user
string

A unique identifier for your end-user. Helps with abuse detection and monitoring.

max_completion_tokens
integer

An upper bound for the number of tokens to generate, including visible output tokens and reasoning tokens. Use this instead of max_tokens for GPT-4.1+, GPT-5 series, and o-series models.

response_format
object

Specifies the output format. Use {"type": "json_object"} for JSON mode, or {"type": "json_schema", "json_schema": {...}} for strict structured output.

tools
object[]

A list of tools the model may call. Currently supports function type tools.

tool_choice
varsayılan:auto

Controls how the model selects tools. auto (default): model decides. none: no tools. required: must call a tool.

logprobs
boolean
varsayılan:false

Whether to return log probabilities of the output tokens.

top_logprobs
integer

Number of most likely tokens to return at each position (0-20). Requires logprobs to be true.

Gerekli aralık: 0 <= x <= 20
reasoning_effort
enum<string>

Controls the reasoning effort for o-series and GPT-5.1+ models.

Mevcut seçenekler:
low,
medium,
high
stream_options
object

Options for streaming. Only valid when stream is true.

service_tier
enum<string>

Specifies the processing tier.

Mevcut seçenekler:
auto,
default,
flex,
priority

Yanıt

Successful chat completion response.

id
string

Unique completion identifier.

Örnek:

"chatcmpl-abc123"

object
enum<string>

Object type. Non-streaming responses use chat.completion.

Mevcut seçenekler:
chat.completion
Örnek:

"chat.completion"

created
integer

Unix timestamp of creation.

Örnek:

1774412483

model
string

The model used (may include version suffix).

Örnek:

"gpt-5.4-2026-03-05"

choices
object[]

Array of completion choices.

usage
object

Token accounting for this request. Billing uses these counts.

service_tier
string

Service tier that processed the request, when the provider reports one.

Örnek:

"default"

system_fingerprint
string | null

Provider backend configuration fingerprint, when the provider reports one.

Örnek:

"fp_490a4ad033"