BazaarLinkBazaarLink
ログイン
ドキュメントAPIリファレンスSDKリファレンスエージェント利用AIスキル
目次

Responses API

Responses API

ステートレスなマルチターン会話、ツールコール、マルチモーダル入力に対応するOpenAI Responses API互換エンドポイント。OpenAI Python SDK ≥ 1.xのclient.responses.create()を使用するエージェントやフレームワークに最適。

POST/v1/responses
Note
Chat Completionsと同じ認証とモデルルーティングを使用。

リクエストボディ

model必須
string
GET /v1/modelsに掲載されたidまたはaliasを使用します(例: "claude-sonnet-4.6"、"anthropic/claude-sonnet-4.6")。
input必須
string | Item[]
ユーザー入力 — プレーンな文字列(単一メッセージ)またはマルチターン/マルチモーダル会話用の入力アイテムの配列。
instructions
string
システムレベルの指示、システムメッセージに相当。リクエストごとに再送信が必要。
stream
boolean
trueの場合、Responses API SSEストリームイベントを返す。イベントタイプ:response.created、response.output_text.delta、response.completed。
max_output_tokens
integer
生成する最大出力トークン数(oシリーズモデルの推論トークンを含む)。
temperature
number
サンプリング値は範囲検証なしで転送されます。モデルが対応範囲外の値を制限または無視する場合があります。
top_p
number
Nucleusサンプリングの確率質量。デフォルト:1
tools
Tool[]
ツール(関数)定義 — Chat Completions と同じ JSON Schema 形式(フラットな Responses 形式とネスト形式の両方を受け付けます)。OpenAI 独自の組み込み型ホスト済みツール(web_search_preview、file_search、computer_use_preview)は非対応です。Web 検索は plugins: [{id:"web"}] で利用できます——一部のモデルルートのみ対応。
tool_choice
string | object
ツール使用の制御:"auto"、"none"、または特定のツール
parallel_tool_calls
boolean
ツール提供時の並列ファンクションコールを有効化。デフォルト:true。OpenAI系モデルのみ対応 — 下記の注記を参照。
response_format
object
構造化JSON出力を強制。構造化出力セクションを参照
previous_response_id
string
このエンドポイントはステートレスです——非 null の値を渡すと即座に 400(invalid_prompt)を返します。受け付けられて無視されることはありません。代わりにステートレスモードを使用してください:input 配列に完全な会話履歴を渡します。

リクエストスキーマ(TypeScript)

type ResponsesRequest = {
  model: string;                    // Listed id or alias from GET /v1/models
  input: string | InputItem[];      // string or multi-turn array

  // Optional
  instructions?: string;            // System-level message
  stream?: boolean;                 // Default: false
  max_output_tokens?: number;
  temperature?: number;
  top_p?: number;
  tools?: Tool[];
  tool_choice?: "auto" | "none" | "required" | object;
  parallel_tool_calls?: boolean;    // Default: true
  previous_response_id?: string;    // Not supported — use full input array
};

type InputItem =
  | { type?: "message"; role: "user" | "assistant" | "system" | "developer"; content: string | ContentBlock[] }
  | { type: "function_call_output"; call_id: string; output: string }   // tool result
  | { type: "function_call"; call_id: string; name: string; arguments: string };

type ContentBlock =
  | { type: "input_text"; text: string }
  | { type: "input_image"; image_url: string; detail?: "auto" | "low" | "high" };

リクエスト例

curl https://api.bazaarlink.ai/v1/responses \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4-mini",
    "instructions": "You are a helpful assistant.",
    "input": "What is the capital of Taiwan?"
  }'

レスポンス形式

BazaarLinkは標準化されたレスポンスを返し、アップストリーム固有のフィールドを削除します。レスポンス内の不透明なBazaarLinkリクエストIDはx-request-idと一致します。GET /v1/generationで使用してください。非ストリーミングのレスポンスでは、同じIDがx-generation-idにも返されます。usage.costはお客様に請求されたUSD金額です。統計は完了後数秒かかる場合があるため、404は短時間再試行してください。

// Non-streaming response object
type ResponsesResponse = {
  id: string;             // Opaque BazaarLink request id; format may change
  object: "response";
  created_at: number;
  completed_at: number;
  status: "completed" | "failed" | "incomplete";
  model: string;
  output: OutputItem[];
  usage: {
    input_tokens: number;   // equivalent to prompt_tokens
    output_tokens: number;  // equivalent to completion_tokens
    total_tokens: number;
    cost?: number;          // USD amount charged to the customer for this request
  } | null;
  error: null | { code: string; message: string };
};

type OutputItem =
  | {
      type: "message";
      id: string;
      role: "assistant";
      status: "completed";
      content: Array<{ type: "output_text"; text: string; annotations: [] }>;
    }
  | { type: "function_call"; id: string; call_id: string; name: string; arguments: string; status: "completed" };

Chat Completionsからの移行

messagesをinput(文字列または配列)に置き換え、システムロールメッセージの代わりにinstructionsを使用し、choices[0].message.contentの代わりにoutput[0].content[0].textを読み取ります。

# Chat Completions (before)
response = client.chat.completions.create(
    model="openai/gpt-5.4-mini",
    messages=[
        {"role": "system", "content": "You are helpful."},
        {"role": "user",   "content": "Hello"},
    ]
)
text = response.choices[0].message.content

# Responses API (after)
response = client.responses.create(
    model="openai/gpt-5.4-mini",
    instructions="You are helpful.",
    input="Hello"
)
text = response.output[0].content[0].text

制限事項

  • previous_response_id または store: true を渡すと 400(エラーコード invalid_prompt)を返します——受け付けられて無視されるわけではありません。常にステートレスモードを使用し、input 配列に完全な会話履歴を渡してください。
  • OpenAI 独自の組み込み型ホスト済みツール(web_search_preview、file_search、computer_use_preview)は非対応です。Web 検索は plugins: [{id:"web"}] で利用できます——一部のモデルルートのみ対応。
  • background: true は受け付けられますが無視されます——すべてのリクエストは完了まで同期的に実行されます。
サポート
こんにちは。どのようなご用件でしょうか?
メッセージをお送りください。担当者より返信します。
Responses API | BazaarLink