/chat/completions
チャット会話に対するモデルの応答を作成します。インタラクティブなAIアプリケーションの主要なエンドポイントです。
POST
/v1/chat/completions指定されたチャット会話に対するモデルの応答を作成します。
リクエストボディ
model使用するモデルのID(必須)messages会話を構成するメッセージのリスト(必須)temperatureサンプリング温度 0-2(デフォルト: 1)。高いほどランダムmax_tokens生成する最大トークン数streamサーバー送信イベントでストリーミング(デフォルト: false)top_p核サンプリングしきい値 0-1(temperatureの代替)toolsモデルが呼び出せるツール(関数)のリストtool_choiceツール使用の制御: 'auto'、'none'、または特定のツールreasoning思考(推論)の制御。{"effort": "low"} で強度、{"max_tokens": 2000} で思考トークンの上限、{"enabled": false} でオフ。対応モデルと既定値は 思考(推論)の制御を参照Request Body
{
"model": "your-model",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"temperature": 0.7,
"max_tokens": 1000,
"reasoning": {"effort": "low"},
"stream": false
}レスポンス
選択肢、使用量メトリクス、終了理由を含むチャット補完オブジェクトを返します。
Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677858242,
"model": "your-model",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 12,
"total_tokens": 32,
"completion_tokens_details": {
"reasoning_tokens": 0
}
}
}推論モデルでは、思考の本文が message.reasoning_content(ストリーミングでは delta.reasoning_content)に入り、そのトークン数が usage.completion_tokens_details.reasoning_tokens に出ます。思考トークンは completion_tokens に含まれ、出力単価で課金されます。