Chat Completions
POST /v1/chat/completions
주어진 채팅 대화에 대한 모델 응답을 생성합니다. OpenAI Chat Completions API와 호환됩니다.
요청 본문
| 매개변수 | 유형 | 설명 |
|---|---|---|
model* | string | 사용할 모델 ID(예: gpt-5.4, qwen3.5-flash, gemini-2.5-flash). |
messages* | array | 대화의 메시지 목록. 각 항목은 role과 content를 가집니다. |
stream | boolean | true이면 SSE 이벤트 streaming을 반환합니다. 기본값: false. |
temperature | number | 샘플링 temperature 0–2. 값이 클수록 더 무작위적입니다. 기본값: 1. |
max_tokens | integer | 생성할 최대 token 수. 상한은 모델에 따라 다릅니다. |
top_p | number | Nucleus 샘플링 확률. 0–1. 기본값: 1. |
stop | string[] | 최대 4개의 시퀀스로, 해당 시퀀스에 도달하면 생성을 중지합니다. |
n | integer | 생성할 완성 후보 수. 기본값: 1. |
요청 예시
POST /v1/chat/completions
Authorization: Bearer YOUR_API_KEY
{
"model": "gpt-5.4-mini",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"temperature": 0.7,
"max_tokens": 256
} 응답 예시
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1714000000,
"model": "qwen3.5-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 26,
"completion_tokens": 9,
"total_tokens": 35
}
} 이 엔드포인트는 게이트웨이 뒤의 모든 제공업체로 라우팅됩니다. model을 model price comparison에서 선택하면 토큰당 가격을 나란히 비교할 수 있습니다.