채팅 완성
OpenAI 호환 메시지, 도구, 스트리밍을 사용하는 POST /v1/chat/completions.
POST https://api.webway.sh/v1/chat/completions
Chat Completions 프로토콜을 사용하는 OpenAI SDK 및 클라이언트에서 이 엔드포인트를 사용하세요.
요청
curl https://api.webway.sh/v1/chat/completions \
-H "Authorization: Bearer $WEBWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.6-terra",
"messages": [{"role": "user", "content": "Say hello."}],
"max_tokens": 128
}'
| 필드 | 타입 | 설명 |
|---|---|---|
model |
문자열 | 필수. 제공업체가 포함된 모델 ID |
messages |
배열 | 필수. system, user, assistant 메시지 |
max_tokens |
정수 | 생성할 최대 토큰 수 |
temperature |
숫자 | 샘플링 온도 |
tools |
배열 | OpenAI 호환 함수 정의 |
tool_choice |
문자열 또는 객체 | 도구 선택을 제어 |
stream |
불리언 | true이면 서버 전송 이벤트로 스트리밍 |
선택한 모델이 지원하는 경우 제공업체별 필드는 그대로 전달됩니다.
응답
{
"id": "chatcmpl_01…",
"object": "chat.completion",
"model": "openai/gpt-5.6-terra",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello!"},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 9, "completion_tokens": 2, "total_tokens": 11}
}
stream: true인 경우 각 SSE data: 줄에는 chat.completion.chunk가 담기며,
스트림은 data: [DONE]으로 끝납니다.