Skip to main content
POST
OpenAI 호환 채팅 완성 API를 통해 대화를 전송하세요. SDK를 base_url="https://api.cometapi.com/v1" 및 CometAPI API 키로 구성하세요. 기본, 이미지, 스트리밍(Streaming), 구조화된 출력 예제에서는 gpt-6-astra를 사용합니다. 함수 호출(Function Calling) 예제에서는 gpt-5.6-sol를 사용하고, 로그 확률 예제에서는 gpt-4.1를 사용합니다.
다음 OpenAI 채팅 완성 참조 에서 파라미터 정의를 확인하세요. GPT-6 Astra 함수 호출(Function Calling)에는 응답을 사용하고 OpenAI 모델 가이드를 따르세요..

메시지 역할

developer Astra 예시를 사용할 때 사용자 메시지 전에 GPT-6 메시지에 애플리케이션 지침을 배치하세요.

멀티모달(Multimodal) 입력 전송

텍스트와 함께 이미지를 전송하려면 콘텐츠 부분 배열을 사용하세요:
이미지 처리 세부 수준을 선택하려면 image_url.detail을 사용하세요. 이 예에서는 high 값을 사용합니다.

응답 스트리밍

증분 출력을 받으려면 streamtrue로 설정하세요. 응답은 다음 방식으로 전달됩니다 서버 전송 이벤트(SSE). 텍스트는 chat.completion.chunk 객체로 도착하며, 이 축약된 예제에는 최종 사용량 청크가 포함되어 있습니다:
스트리밍 응답에 토큰 사용량 통계를 포함하려면 stream_options.include_usagetrue로 설정하세요. 사용량 데이터는 [DONE] 전에 최종 청크에 표시됩니다. 청크의 choices 배열은 비어 있을 수 있으므로 choices[0]에 액세스하기 전에 확인하세요.

구조화된 출력 요청

구조화된 출력을 요청하려면 response_format을 사용하세요:
JSON Schema 모드는 필요한 구조를 지정합니다. JSON Object 모드는 스키마를 강제하지 않고 유효한 JSON을 요청합니다. 결과를 사용하기 전에 거부 응답 또는 길이 제한 응답인지 확인하세요.

도구 및 함수 호출

함수 정의와 함께 gpt-5.6-sol을 사용하세요:
함수 호출은 finish_reason: "tool_calls"message.tool_calls 배열을 반환합니다. 함수의 JSON으로 인코딩된 arguments를 파싱하고 함수를 실행한 다음, 어시스턴트 메시지와 일치하는 tool를 포함한 tool_call_id 결과 메시지를 추가하세요.

요청 파라미터 선택

Astra에서 reasoning_effortmax_completion_tokens을 사용하세요. Functions 및 Logprobs 예제에서는 각각 GPT-6 및 gpt-5.6-sol에 대한 요청 옵션을 보여 줍니다. gpt-4.1Claude 또는 Gemini 전용 요청 형식은 다음을 참조하세요 Anthropic 메시지Gemini 콘텐츠 생성.
Astra 예제에서 생성되는 토큰(Token)을 제한하려면 max_completion_tokens을 사용하세요. 여기에는 추론과 표시되는 출력이 포함되므로 둘 모두를 위한 여유를 확보하세요. GPT-6 max_tokens은 레거시 파라미터입니다.
Astra 예제에서 애플리케이션 지침에는 developer을 사용하세요. 최종 사용자 콘텐츠는 GPT-6 user 메시지에 유지하고, 대화를 계속할 때는 이전 어시스턴트 응답을 보존하세요.

자주 묻는 질문

속도 제한을 처리하는 방법은 무엇인가요?

429 Too Many Requests 발생 시 지수 백오프를 구현하세요:

대화 컨텍스트를 유지하는 방법은 무엇인가요?

전체 대화 기록을 messages 배열에 포함하세요:

finish_reason의 의미는 무엇인가요?

비용을 제어하는 방법은 무엇인가요?

  1. 출력 길이를 제한하려면 max_completion_tokens을 사용하세요.
  2. 모델 가격을 비교하고 워크로드 요구 사항에 맞는 모델을 선택하세요.
  3. 프롬프트(Prompt)를 간결하게 유지하세요. 중복된 컨텍스트는 피하세요.
  4. usage 응답 필드에서 토큰(Token) 사용량을 모니터링하세요.

인증

Authorization
string
header
필수

Bearer token authentication. Use your CometAPI key.

본문

application/json
model
string
기본값:gpt-6-astra
필수

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

예시:

"gpt-6-astra"

messages
object[]
필수

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.

필수 범위: 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.

필수 범위: 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
지원 중단

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.

필수 범위: -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.

필수 범위: -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.

필수 범위: 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.

사용 가능한 옵션:
auto,
default,
flex,
priority

응답

Successful chat completion response.

id
string

Unique completion identifier.

예시:

"chatcmpl_example"

object
enum<string>

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

사용 가능한 옵션:
chat.completion
예시:

"chat.completion"

created
integer

Unix timestamp of creation.

예시:

1788763703

model
string

The model used (may include version suffix).

예시:

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

마지막 수정일 2026년 9월 8일