Ana içeriğe atla
POST
OpenAI uyumlu Chat Completions API aracılığıyla konuşmalar 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 yapılandırılmış çıktı örnekleri gpt-6-astra kullanır. Function Calling örneği gpt-6.1-sol, log-probability örneği ise gpt-4.1 kullanır.
Şu kaynağı kullanın: OpenAI Chat Completions referansı parametre tanımları için. GPT-6 Astra araç çağrısı için Responses kullanın ve OpenAI model rehberini takip edin.

Mesaj rolleri

GPT-6 Astra örneklerini kullanırken, uygulama yönergelerini içeren bir developer mesajını kullanıcı mesajlarından önce yerleştirin.

Multimodal girdi gönderme

Metinle birlikte bir görüntü göndermek için içerik parçalarından oluşan bir dizi kullanın:
Görüntü işleme ayrıntı düzeyini 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ğırın

Bir işlev tanımıyla birlikte gpt-6.1-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 çalıştırın, ardından assistant mesajını ve eşleşen tool_call_id içeren bir tool sonuç mesajını ekleyin.

İstek parametrelerini seçin

Astra ile reasoning_effort ve max_completion_tokens kullanın. Functions ve Logprobs örnekleri, sırasıyla GPT-6, gpt-6.1-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.
Astra örneklerinde oluşturulan Token sayısını sınırlamak için max_completion_tokens kullanın. Bu, akıl yürütmeyi ve görünür çıktıyı içerir; bu nedenle her ikisi için de yeterli alan bırakın. GPT-6 ve max_tokens eski parametrelerdir.
GPT-6 Astra örneklerinde uygulama yönergeleri için developer 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 Ekim 2026