Chat completions
OpenAI 互換のメッセージ、ツール、ストリーミングを扱う POST /v1/chat/completions。
POST https://api.webway.sh/v1/chat/completions
OpenAI の SDK や、Chat Completions プロトコルを話すクライアントではこのエンドポイントを 使います。
リクエスト
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 |
string | 必須。プロバイダー修飾子付きのモデル ID |
messages |
array | 必須。system、user、assistant のメッセージ |
max_tokens |
integer | 生成するトークンの上限 |
temperature |
number | サンプリング温度 |
tools |
array | OpenAI 互換の関数定義 |
tool_choice |
string または object | ツールの選択を制御します |
stream |
boolean | true のとき Server-Sent Events でストリーミングします |
選択したモデルが対応していれば、プロバイダー固有のフィールドはそのまま渡されます。
レスポンス
{
"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] で終わります。