Responses (OpenAI)
OpenAI Responses 形式のインバウンドアダプター。OpenAI の Codex CLI は /v1/responses しか話さないため、このエンドポイントで Codex と Responses SDK を接続できます。
OpenAI の Codex CLI は /v1/responses 形式しか話しません。 PleumRouter はこの形式を受け取り内部のモデル呼び出しに変換するインバウンドアダプターを提供するため、 Codex CLI(および OpenAI Responses SDK)をそのまま PleumRouter に接続できます。
接続#
base URL を https://apirouter.pleum.ai/v1 に、API キーを plm_ キーに設定します。Codex では wire_api = "responses" を指定すると、このエンドポイントを呼び出します。
export OPENAI_BASE_URL="https://apirouter.pleum.ai/v1"
export OPENAI_API_KEY="plm_..."OpenAI Responses API (Codex)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "plm_xxxxxxxxxxxxxxxx",
baseURL: "https://apirouter.pleum.ai/v1",
});
const response = await client.responses.create({
model: "gpt-4.1",
input: "Why is the sky blue?",
});
console.log(response.output_text);OpenAI Responses API (Codex)
from openai import OpenAI
client = OpenAI(
api_key="plm_xxxxxxxxxxxxxxxx",
base_url="https://apirouter.pleum.ai/v1",
)
response = client.responses.create(
model="gpt-4.1",
input="Why is the sky blue?",
)
print(response.output_text)OpenAI Responses API (Codex)
curl https://apirouter.pleum.ai/v1/responses \
-H "Authorization: Bearer plm_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1",
"input": "Why is the sky blue?"
}'POST /v1/responses/{request_id}/feedback is a separate routing feedback endpoint (JWT), not Responses create.リクエストボディ#
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
| model | string | 必須 | モデル ID。GET /v1/models で全一覧を確認できます。 |
| input | string | array | 必須 | 文字列、または項目の配列(message / function_call / function_call_output)。 |
| instructions | string | 任意 | system メッセージとして先頭に追加されます。 |
| max_output_tokens | integer | 任意 | デフォルト値 4096。内部の max_tokens にマッピングされます。 |
| temperature | number | 任意 | サンプリング温度。 |
| top_p | number | 任意 | 核サンプリング。 |
| stream | boolean | 任意 | true の場合は Responses SSE ストリーミングレスポンス。 |
| tools | array | 任意 | Responses のフラットな関数ツール({type:"function", name, description, parameters})は変換されます。関数以外のツール(例: web_search)は静かに破棄されます。 |
| tool_choice | string | object | 任意 | 文字列 auto | none | required、または {type:"function", name}。 |
| parallel_tool_calls | boolean | 任意 | 並列ツール呼び出しを許可するか。 |
| metadata | object | 任意 | 任意のキー・値メタデータ。 |
curl https://apirouter.pleum.ai/v1/responses \
-H "Authorization: Bearer $PLEUM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1",
"instructions": "You are a helpful assistant.",
"input": [
{
"type": "message",
"role": "user",
"content": "Hello"
}
],
"max_output_tokens": 4096,
"stream": false
}'レスポンス#
非ストリーミングレスポンスは、アシスタントメッセージを output 配列に入れて 返します。各メッセージの content は output_text パートで 構成され、usage には input_tokens / output_tokens / total_tokens が含まれます。 費用は本文ではなく X-Cost-Krw / X-Cost-Usd レスポンス ヘッダーで返されます。Codex が送る追加フィールド(reasoning、 text、store、 previous_response_id、include、 prompt_cache_key)は受け入れられますが無視されます。
{
"id": "resp_gpt-4.1-841ms",
"object": "response",
"created_at": 1735689600,
"status": "completed",
"model": "gpt-4.1",
"output": [
{
"id": "msg_abc123",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{"type": "output_text", "text": "Hi!", "annotations": []}
]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 5,
"total_tokens": 17
}
}ストリーミング#
stream: true でリクエストすると、Responses SSE イベントが送信されます — response.created → response.in_progress → output_item.added / content_part.added / output_text.delta → output_text.done / output_item.done → 完全な usage を含む response.completed。Codex は完成した項目を output_item.done から読み取り、終了を response.completed で判断します。
data: {"type":"response.created","response":{"id":"resp_abc","status":"in_progress"}}
data: {"type":"response.in_progress","response":{"id":"resp_abc"}}
data: {"type":"output_item.added","item":{"id":"msg_abc","type":"message","role":"assistant"}}
data: {"type":"content_part.added","item_id":"msg_abc","part":{"type":"output_text","text":""}}
data: {"type":"response.output_text.delta","item_id":"msg_abc","delta":"Hi"}
data: {"type":"response.output_text.delta","item_id":"msg_abc","delta":"!"}
data: {"type":"response.output_text.done","item_id":"msg_abc","text":"Hi!"}
data: {"type":"output_item.done","item":{"id":"msg_abc","type":"message","role":"assistant","content":[{"type":"output_text","text":"Hi!"}]}}
data: {"type":"response.completed","response":{"id":"resp_abc","status":"completed","usage":{"input_tokens":12,"output_tokens":5,"total_tokens":17}}}web_search のような組み込みツールは転送されず、静かに破棄されます。{type:"function"} ツールのみが変換され、モデルに渡されます。