Skip to main content
POST
Konuşmaları OpenAI uyumlu Chat Completions API üzerinden gönderin. SDK’nızı base_url="https://api.cometapi.com/v1" ve CometAPI API anahtarınızla yapılandırın. Temel, görüntü, Streaming ve structured-output örnekleri gpt-6-astra kullanır. Function Calling örneği gpt-5.6-sol, log-probability örneği ise gpt-4.1 kullanır.
Şunu kullanın: OpenAI Chat Completions referansı parametre tanımları için. GPT-6 Astra tool calling için şunu kullanın: Responses, şu kılavuzu izleyerek: OpenAI model kılavuzu.

Mesaj rolleri

developer Astra örneklerini kullanırken uygulama talimatlarını kullanıcı mesajlarından önce bir GPT-6 mesajına yerleştirin.

Multimodal girdi gönderme

Metinle birlikte görüntü göndermek için bir content part dizisi kullanın:
Görüntü işleme ayrıntısını seçmek için image_url.detail kullanın. Bu örnek high kullanır.

Yanıtları akış olarak alın

Artımlı çıktı almak için stream değerini true olarak ayarlayın. Yanıt şu şekilde gönderilir: Sunucu Tarafından Gönderilen Olaylar (SSE). Metin, chat.completion.chunk nesneleri içinde gelir; bu kısaltılmış örnek son kullanım parçasını içerir:
Akış yanıtlarına Token kullanım istatistiklerini dahil etmek için stream_options.include_usage değerini true olarak ayarlayın. Kullanım verileri, [DONE] öncesindeki son parçada görünür. Parçalar boş bir choices dizisine sahip olabilir; choices[0] öğesine erişmeden önce bunu kontrol edin.

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

Yapılandırılmış çıktı istemek için response_format kullanın:
JSON Schema modu gerekli yapıyı belirtir. JSON Object modu, şemanızı zorlamadan geçerli JSON ister. Sonucu kullanmadan önce ret yanıtı veya uzunlukla sınırlı bir yanıt olup olmadığını kontrol edin.

Araçları ve işlevleri çağırma

Bir işlev tanımıyla birlikte gpt-5.6-sol kullanın:
Bir işlev çağrısı, finish_reason: "tool_calls" ve bir message.tool_calls dizisi döndürür. İşlevin JSON ile kodlanmış arguments değerini ayrıştırın, işlevinizi yürütün, ardından assistant mesajını ve eşleşen tool değerini içeren bir tool_call_id sonuç mesajını ekleyin.

İstek parametrelerini seçme

reasoning_effort ve max_completion_tokens ile GPT-6 Astra kullanın. Functions ve Logprobs örnekleri sırasıyla gpt-5.6-sol ve gpt-4.1 için istek seçeneklerini gösterir.Claude veya Gemini’ye özgü istek biçimleri için bkz. Anthropic Messages ve Gemini Generate content.
max_completion_tokens değerini, GPT-6 Astra örnekleri için üretilen token’ları sınırlamak üzere kullanın. Buna reasoning ve görünür çıktı dahildir; bu nedenle her ikisi için de yeterli alan bırakın. max_tokens eski bir parametredir.
developer değerini, GPT-6 Astra örneklerindeki uygulama yönergeleri için kullanın. Son kullanıcı içeriğini user mesajlarında tutun ve bir konuşmaya devam ederken önceki assistant yanıtlarını koruyun.

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 ne anlamagelir?

Maliyetler nasıl kontrol edilir?

  1. Çıktı uzunluğunu sınırlamak için max_completion_tokens kullanın.
  2. Model fiyatlandırmalarını karşılaştırın ve iş yükü gereksinimlerinizi karşılayan bir model seçin.
  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-6-astra
gerekli

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

Örnek:

"gpt-6-astra"

messages
object[]
gerekli

Conversation messages, including instructions, user input, assistant replies, and tool results.

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

Sampling temperature. Omit this field for GPT-6 Astra.

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

Nucleus sampling threshold. Omit this field for GPT-6 Astra. For sampling overrides, adjust either top_p or temperature.

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

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

stop

Stop string or list of up to four strings, for models that support stop sequences.

max_tokens
integer
kullanımdan kaldırıldı

Legacy output-token limit. Use max_completion_tokens for the GPT-6 Astra examples.

presence_penalty
number

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

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

Maximum generated tokens, including visible output and reasoning. Leave enough room for both, as in the image-input example.

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[]

Function definitions for a model that supports tool calling on Chat Completions. The function example uses GPT-5.6 Sol; use Responses for GPT-6 Astra tool calls.

tool_choice

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

logprobs
boolean

Return token log probabilities. Use gpt-4.1 as shown in the Logprobs example.

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
string

Reasoning effort supported by the selected model. The GPT-6 Astra examples use low; the GPT-5.6 Sol function example uses none. See the model reference for other supported levels.

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_example"

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:

1788763703

model
string

The model used (may include version suffix).

Örnek:

"gpt-6-astra"

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 returned.

system_fingerprint
string | null

Model configuration fingerprint, when returned.

Son değiştirilme tarihi 8 Eylül 2026