すべてのプロダクト
Search
ドキュメントセンター

Alibaba Cloud Model Studio:OpenAI 応答 API リファレンス

最終更新日:Mar 26, 2026

OpenAI 互換の Responses API を使用して Qwen モデルを呼び出します。

OpenAI チャット完了 API との比較における利点

  • 組み込みツール:Web 検索、Web スクレイピング、コードインタープリター、テキストによる画像検索、画像による画像検索、ナレッジベース検索を含む — 複雑なタスクにおいてより優れた結果を提供します。詳細については、「ツール呼び出し」をご参照ください。

  • 柔軟性の高い入力形式:モデル入力として文字列を直接渡すことが可能であり、チャット形式のメッセージ配列にも対応しています。

  • 簡素化されたコンテキスト管理:メッセージ履歴配列を手動で構築する代わりに、previous_response_id を渡します。

互換性に関する注意事項と制限事項

本 API は移行コストを低減するために OpenAI 互換を採用していますが、パラメーター、機能、動作には差異があります。

基本原則:明示的にドキュメント化されたパラメーターのみが処理されます。OpenAI の非公式パラメーターは無視されます。

以下は、迅速な適応を支援するための主な差異です:

  • サポートされていないパラメーター:OpenAI Responses API の一部のパラメーター(例:background)はサポートされていません。現在は同期呼び出しのみがサポートされています。

  • 追加パラメーター:本 API では、enable_thinking などの追加パラメーターがサポートされています。具体的な使用方法については、対応するパラメーターの説明をご参照ください。

シンガポール

SDK 用の base_urlhttps://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1

HTTP エンドポイント:POST https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses

China (Beijing)

SDK 用の base_urlhttps://dashscope.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1

HTTP エンドポイント:POST https://dashscope.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses

米国 (バージニア)

SDK 用の base_urlhttps://dashscope-us.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1

HTTP エンドポイント:POST https://dashscope-us.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses

リクエストボディ

基本的な呼び出し

Python

import os
from openai import OpenAI

client = OpenAI(
    # 環境変数が設定されていない場合は、api_key="sk-xxx" に置き換えます
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",
)

response = client.responses.create(
    model="qwen3.5-plus",
    input="何ができますか?"
)

# モデルの応答を取得
print(response.output_text)

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    // 環境変数が設定されていない場合は、apiKey: "sk-xxx" に置き換えます
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
});

async function main() {
    const response = await openai.responses.create({
        model: "qwen3.5-plus",
        input: "何ができますか?"
    });

    // モデルの応答を取得
    console.log(response.output_text);
}

main();

curl

curl -X POST https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-plus",
    "input": "何ができますか?"
}'

ストリーミング出力

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",
)

stream = client.responses.create(
    model="qwen3.5-plus",
    input="人工知能について簡単に紹介してください。",
    stream=True
)

print("ストリーミング出力を受信中:")
for event in stream:
    if event.type == 'response.output_text.delta':
        print(event.delta, end='', flush=True)
    elif event.type == 'response.completed':
        print("\nストリーミング完了")
        print(f"合計トークン数:{event.response.usage.total_tokens}")

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
});

async function main() {
    const stream = await openai.responses.create({
        model: "qwen3.5-plus",
        input: "人工知能について簡単に紹介してください。",
        stream: true
    });

    console.log("ストリーミング出力を受信中:");
    for await (const event of stream) {
        if (event.type === 'response.output_text.delta') {
            process.stdout.write(event.delta);
        } else if (event.type === 'response.completed') {
            console.log("\nストリーミング完了");
            console.log(`合計トークン数:${event.response.usage.total_tokens}`);
        }
    }
}

main();

curl

curl -X POST https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
--no-buffer \
-d '{
    "model": "qwen3.5-plus",
    "input": "人工知能について簡単に紹介してください。",
    "stream": true
}'

マルチターン対話

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",
)

# 最初のラウンド
response1 = client.responses.create(
    model="qwen3.5-plus",
    input="私の名前は田中一郎です。覚えておいてください。"
)
print(f"最初の応答:{response1.output_text}")

# 2 回目のラウンド — コンテキストを関連付けるために previous_response_id を使用
# 応答 ID は 7 日間有効です
response2 = client.responses.create(
    model="qwen3.5-plus",
    input="私の名前を覚えていますか?",
    previous_response_id=response1.id
)
print(f"2 回目の応答:{response2.output_text}")

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
});

async function main() {
    // 最初のラウンド
    const response1 = await openai.responses.create({
        model: "qwen3.5-plus",
        input: "私の名前は田中一郎です。覚えておいてください。"
    });
    console.log(`最初の応答:${response1.output_text}`);

    // 2 回目のラウンド — コンテキストを関連付けるために previous_response_id を使用
    // 応答 ID は 7 日間有効です
    const response2 = await openai.responses.create({
        model: "qwen3.5-plus",
        input: "私の名前を覚えていますか?",
        previous_response_id: response1.id
    });
    console.log(`2 回目の応答:${response2.output_text}`);
}

main();

組み込みツールの呼び出し

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",
)

response = client.responses.create(
    model="qwen3.5-plus",
    input="Alibaba Cloud のウェブサイトを検索し、主要情報を抽出してください。",
    # 最良の結果を得るため、組み込みツールを有効化することを推奨します
    tools=[
        {"type": "web_search"},
        {"type": "code_interpreter"},
        {"type": "web_extractor"}
    ],
    extra_body={"enable_thinking": True}
)

# 中間出力を確認する場合は、下記の行のコメントを解除してください
# print(response.output)
print(response.output_text)

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1"
});

async function main() {
    const response = await openai.responses.create({
        model: "qwen3.5-plus",
        input: "Alibaba Cloud のウェブサイトを検索し、主要情報を抽出してください。",
        tools: [
            { type: "web_search" },
            { type: "code_interpreter" },
            { type: "web_extractor" }
        ],
        enable_thinking: true
    });

    for (const item of response.output) {
        if (item.type === "reasoning") {
            console.log("モデルが思考中...");
        } else if (item.type === "web_search_call") {
            console.log(`検索クエリ:${item.action.query}`);
        } else if (item.type === "web_extractor_call") {
            console.log("Web コンテンツを抽出中...");
        } else if (item.type === "message") {
            console.log(`応答:${item.content[0].text}`);
        }
    }
}

main();

curl

curl -X POST https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1/responses \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-plus",
    "input": "Alibaba Cloud のウェブサイトを検索し、主要情報を抽出してください。",
    "tools": [
        {
            "type": "web_search"
        },
        {
            "type": "code_interpreter"
        },
        {
            "type": "web_extractor"
        }
    ],
    "enable_thinking": true
}'

カスタム関数呼び出し

Python

from openai import OpenAI
import json
import os
import random

# クライアントを初期化
client = OpenAI(
    # 環境変数が設定されていない場合は、api_key="sk-xxx" を直接指定
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",
)
# ユーザーの質問をシミュレート
USER_QUESTION = "東京の天気はどうですか?"
# ツールのリストを定義
tools = [
    {
        "type": "function",
        "name": "get_current_weather",
        "description": "指定された都市の天気を照会します。",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {
                    "type": "string",
                    "description": "東京、杭州、余杭区などの都市または地区。",
                }
            },
            "required": ["location"],
        },
    }
]


# 天気照会ツールをシミュレート
def get_current_weather(arguments):
    weather_conditions = ["晴れ", "曇り", "雨"]
    random_weather = random.choice(weather_conditions)
    location = arguments["location"]
    return f"{location}では、本日{random_weather}です。"


# モデルの応答を取得する関数を定義
def get_response(input_data):
    response = client.responses.create(
        model="qwen3.5-plus",  # オプション:qwen3.5-flash、qwen3.5-flash-2026-02-23
        input=input_data,
        tools=tools,
    )
    return response


# 対話コンテキストを維持
conversation = [{"role": "user", "content": USER_QUESTION}]

response = get_response(conversation)
function_calls = [item for item in response.output if item.type == "function_call"]
# ツール呼び出しが不要な場合、内容を直接出力
if not function_calls:
    print(f"最終的なアシスタントの応答:{response.output_text}")
else:
    # ツール呼び出しループに入ります
    while function_calls:
        for fc in function_calls:
            func_name = fc.name
            arguments = json.loads(fc.arguments)
            print(f"ツール [{func_name}] を呼び出し中、引数:{arguments}")
            # ツールを実行
            tool_result = get_current_weather(arguments)
            print(f"ツールの戻り値:{tool_result}")
            # ツール呼び出しとその結果をペアとしてコンテキストに追加
            conversation.append(
                {
                    "type": "function_call",
                    "name": fc.name,
                    "arguments": fc.arguments,
                    "call_id": fc.call_id,
                }
            )
            conversation.append(
                {
                    "type": "function_call_output",
                    "call_id": fc.call_id,
                    "output": tool_result,
                }
            )
        # 完全なコンテキストで再度モデルを呼び出し
        response = get_response(conversation)
        function_calls = [
            item for item in response.output if item.type == "function_call"
        ]
    print(f"最終的なアシスタントの応答:{response.output_text}")

Node.js

import OpenAI from "openai";

// クライアントを初期化
const openai = new OpenAI({
  // 環境変数が設定されていない場合は、apiKey: "sk-xxx" を直接指定
  apiKey: process.env.DASHSCOPE_API_KEY,
  baseURL:
    "https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",
});

// ツールのリストを定義
const tools = [
  {
    type: "function",
    name: "get_current_weather",
    description: "指定された都市の天気を照会します。",
    parameters: {
      type: "object",
      properties: {
        location: {
          type: "string",
          description: "東京、杭州、余杭区などの都市または地区。",
        },
      },
      required: ["location"],
    },
  },
];

// 天気照会ツールをシミュレート
const getCurrentWeather = (args) => {
  const weatherConditions = ["晴れ", "曇り", "雨"];
  const randomWeather =
    weatherConditions[Math.floor(Math.random() * weatherConditions.length)];
  const location = args.location;
  return `${location}では、本日${randomWeather}です。`;
};

// モデルの応答を取得する関数を定義
const getResponse = async (inputData) => {
  const response = await openai.responses.create({
    model: "qwen3.5-plus",  // オプション:qwen3.5-flash、qwen3.5-flash-2026-02-23
    input: inputData,
    tools: tools,
  });
  return response;
};

const main = async () => {
  const userQuestion = "東京の天気はどうですか?";

  // 対話コンテキストを維持
  const conversation = [{ role: "user", content: userQuestion }];

  let response = await getResponse(conversation);
  let functionCalls = response.output.filter(
    (item) => item.type === "function_call"
  );
  // ツール呼び出しが不要な場合、内容を直接出力
  if (functionCalls.length === 0) {
    console.log(`最終的なアシスタントの応答:${response.output_text}`);
  } else {
    // ツール呼び出しループに入ります
    while (functionCalls.length > 0) {
      for (const fc of functionCalls) {
        const funcName = fc.name;
        const args = JSON.parse(fc.arguments);
        console.log(`ツール [${funcName}] を呼び出し中、引数:`, args);
        // ツールを実行
        const toolResult = getCurrentWeather(args);
        console.log(`ツールの戻り値:${toolResult}`);
        // ツール呼び出しとその結果をペアとしてコンテキストに追加
        conversation.push({
          type: "function_call",
          name: fc.name,
          arguments: fc.arguments,
          call_id: fc.call_id,
        });
        conversation.push({
          type: "function_call_output",
          call_id: fc.call_id,
          output: toolResult,
        });
      }
      // 完全なコンテキストで再度モデルを呼び出し
      response = await getResponse(conversation);
      functionCalls = response.output.filter(
        (item) => item.type === "function_call"
      );
    }
    console.log(`最終的なアシスタントの応答:${response.output_text}`);
  }
};

// プログラムを開始
main().catch(console.error);

model 文字列 (必須)

サポートされるモデル

国際

qwen3-maxqwen3-max-2026-01-23qwen3.5-plusqwen3.5-plus-2026-02-15qwen3.5-flashqwen3.5-flash-2026-02-23qwen3.5-397b-a17bqwen3.5-122b-a10bqwen3.5-27bqwen3.5-35b-a3bqwen-plusqwen-flashqwen3-coder-plusqwen3-coder-flash

グローバル

米国 (バージニア) リージョン:qwen3-maxqwen3.5-plusqwen3.5-plus-2026-02-15qwen3.5-flashqwen3.5-flash-2026-02-23qwen3.5-397b-a17bqwen3.5-122b-a10bqwen3.5-27bqwen3.5-35b-a3bqwen-plusqwen-flashqwen3-coder-plusqwen3-coder-flash

中国本土

qwen3-maxqwen3-max-2026-01-23qwen3.5-plusqwen3.5-plus-2026-02-15qwen3.5-flashqwen3.5-flash-2026-02-23qwen3.5-397b-a17bqwen3.5-122b-a10bqwen3.5-27bqwen3.5-35b-a3bqwen-plusqwen-flashqwen3-coder-plusqwen3-coder-flash

input 文字列または配列 (必須)

モデル入力。以下のフォーマットがサポートされています:

  • 文字列:単純なテキスト入力(例:"こんにちは")。

  • 配列:会話順に並べられたメッセージ配列。

配列メッセージのタイプ

システムメッセージ オブジェクト (任意)

モデルの役割、トーン、目的、または制約を設定します。

プロパティ

role 文字列 (必須)

メッセージの役割。値は system である必要があります。

content 文字列 (必須)

モデルの役割、動作、応答スタイル、および制約を定義するシステム命令。

開発者メッセージ オブジェクト (任意)

システムメッセージと同じ機能 — モデルの役割と動作を設定します。

プロパティ

role 文字列 (任意)

メッセージの役割。値は developer である必要があります。

content 文字列 (任意)

モデルの役割、動作、応答スタイル、および制約を定義する開発者命令。

ユーザー・メッセージ オブジェクト (必須)

質問、命令、またはコンテキストをモデルに渡します。

プロパティ

role 文字列 (必須)

メッセージの役割。値は user である必要があります。

content 文字列または配列 (必須)

メッセージ本文。テキストのみの入力の場合は文字列、画像または明示的なキャッシュの場合は配列を使用します。

Responses API は動画または音声入力に対応していません。代わりに「チャット完了 API」または「DashScope API」をご利用ください。

プロパティ

type 文字列 (必須)

有効な値:

  • text

  • input_image

text 文字列

入力テキスト。typetext の場合に必須です。

image_url 文字列

入力画像のパブリック URL または Base64 エンコード済みデータ。typeimage_url の場合に必須です。ローカルファイルをアップロードする場合は、「画像および動画の理解をご参照ください。

アシスタント・メッセージ オブジェクト (任意)

マルチターン対話のコンテキストとして使用される以前のモデル応答を含みます。

プロパティ

role 文字列 (必須)

メッセージの役割。値は assistant である必要があります。

content 文字列 (必須)

アシスタントの返信のテキスト本文。

instructions 文字列 (任意)

コンテキストの先頭に挿入されるシステム命令。previous_response_id を使用する場合、以前の instructions は継承されません。

previous_response_id 文字列 (任意)

以前の応答の固有 ID(有効期限:7 日間)。マルチターン対話に使用します — サーバーが自動的にそのターンの入力と出力をコンテキストとして取得・結合します。input 配列と previous_response_id の両方が指定されている場合、新しいメッセージが履歴コンテキストに追加されます。conversation と併用できません。

conversation 文字列 (任意)

現在の応答の対話 ID。履歴項目は自動的にコンテキストとして渡され、現在のリクエストの入力/出力は完了後に追加されます。previous_response_id と併用できません。

stream ブール値 (任意)デフォルト値:false

ストリーミング出力を有効化します。true の場合、モデル応答がリアルタイムでストリーミングされます。

tools 配列 (任意)

応答生成時にモデルが呼び出すことができるツール。組み込みツールおよびユーザー定義関数ツールをサポートします。

最良の結果を得るため、code_interpreterweb_search、および web_extractor を同時に有効化することを推奨します。

プロパティ

web_search

モデルが最新情報をオンラインで検索できるようにします。詳細については、「Web 検索」をご参照ください。

プロパティ

type 文字列 (必須)

値は web_search である必要があります。

例:[{"type": "web_search"}]

web_extractor

モデルが Web ページのコンテンツを抽出できるようにします。web_search と併用する必要があります。qwen3-max および qwen3-max-2026-01-23 モデルでは思考モードが必要です。詳細については、「Web 抽出器」をご参照ください。

プロパティ

type 文字列 (必須)

値は web_extractor である必要があります。

例:[{"type": "web_search"}, {"type": "web_extractor"}]

code_interpreter

モデルがコードを実行してデータ分析の結果を返すことを許可します。qwen3-max および qwen3-max-2026-01-23 モデルでは思考モードが必要です。詳細については、「コードインタープリター」をご参照ください。

プロパティ

type 文字列 (必須)

値は code_interpreter である必要があります。

例:[{"type": "code_interpreter"}]

web_search_image

テキストによる説明に基づいて画像を検索します。詳細については、「テキストによる画像検索」をご参照ください。

プロパティ

type 文字列 (必須)

値は web_search_image である必要があります。

例:[{"type": "web_search_image"}]

image_search

画像に基づいて類似または関連する画像を検索します。入力には画像 URL を含める必要があります。詳細については、「画像検索」をご参照ください。

プロパティ

type 文字列 (必須)

値は image_search である必要があります。

例:[{"type": "image_search"}]

file_search

アップロード済みまたは関連付けられたナレッジベース内で検索します。詳細については、「ナレッジ検索」をご参照ください。

プロパティ

type 文字列 (必須)

値は file_search である必要があります。

vector_store_ids 配列 (必須)

検索対象のナレッジベースの ID。現在は、1 つのナレッジベース ID のみがサポートされています。

例:[{"type": "file_search", "vector_store_ids": ["your_knowledge_base_id"]}]

MCP 呼び出し

Model Context Protocol(MCP)を介して外部サービスを呼び出します。詳細については、「MCP」をご参照ください。

プロパティ

type 文字列 (必須)

値は mcp である必要があります。

server_protocol 文字列 (必須)

MCP サービスとの通信プロトコル(例:"sse")。

server_label 文字列 (必須)

MCP サービスを識別するサービスラベル。

server_description 文字列 (任意)

サービスの機能や適用シーンをモデルが理解できるよう説明する記述。

server_url 文字列 (必須)

MCP サービスエンドポイントの URL。

headers オブジェクト (任意)

本人確認などの情報を伝達するためのリクエストヘッダー(例:Authorization)。

例:

mcp_tool = {
    "type": "mcp",
    "server_protocol": "sse",
    "server_label": "amap-maps",
    "server_description": "AMAP MCP Server は現在、15 のコア API をカバーしており、専用マップの生成、目的地へのナビゲーション、ライドシェアの手配、ジオコーディング、逆ジオコーディング、IP 位置特定、天気照会、自転車・徒歩・運転・公共交通機関のルート計画、距離測定、キーワード検索、周辺検索、詳細検索など、幅広い地理情報サービスを提供しています。",
    "server_url": "https://dashscope.aliyuncs.com/api/v1/mcps/amap-maps/sse",
    "headers": {
        "Authorization": "Bearer <your-mcp-server-token>"
    }
}

カスタムツール function

ユーザーが定義した関数ツールで、モデルがユーザーが定義した関数を呼び出せるようにします。モデルがツール呼び出しを決定すると、応答には function_call 型の出力が返されます。詳細については、「関数呼び出し」をご参照ください。

プロパティ

type 文字列 (必須)

値は function である必要があります。

name 文字列 (必須)

ツール名。名前には英字、数字、アンダースコア(_)、ハイフン(-)のみ使用可能です。最大長は 64 トークンです。

description 文字列 (必須)

モデルがいつ・どのようにツールを呼び出すかを判断するためのツールの説明。

parameters オブジェクト (任意)

ツールのパラメーターの説明。説明は有効な JSON Schema である必要があります。parameters パラメーターが空の場合、ツールには入力パラメーターがありません(例:時刻照会ツール)。

ツール呼び出しの精度を向上させるため、parameters を渡すことを推奨します。

例:

[
  {
    "type": "function",
    "name": "get_weather",
    "description": "指定された都市の天気情報を取得します",
    "parameters": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string",
          "description": "都市名"
        }
      },
      "required": ["city"]
    }
  }
]

tool_choice 文字列またはオブジェクト (任意)デフォルト値:auto

モデルがツールを選択および呼び出す方法を制御します。文字列またはオブジェクト形式をサポートします。

文字列パターン

  • auto:モデルがツール呼び出しの有無を自動的に判断します。

  • none:モデルによるツール呼び出しを防止します。

  • required:モデルによるツール呼び出しを強制します。tools リストにツールが 1 つだけ存在する場合にのみ使用可能です。

オブジェクト形式

モデルが選択および呼び出すことのできるツールの範囲を指定します。モデルは、あらかじめ定義されたリスト内のツールのみから選択および呼び出すことができます。

プロパティ

mode 文字列 (必須)

  • auto:モデルがツール呼び出しの有無を自動的に判断します。

  • required:モデルによるツール呼び出しを強制します。tools リストにツールが 1 つだけ存在する場合にのみ使用可能です。

tools 配列 (必須)

モデルが呼び出すことを許可されたツール定義のリスト。

[
  { "type": "function", "name": "get_weather" }
]

type 文字列 (必須)

許可されるツール構成のタイプ。値は allowed_tools である必要があります。

temperature 浮動小数点数 (任意)

テキスト多様性を制御するサンプリング温度。値が高いほど多様性が高まり、低いほど決定論的になります。範囲:[0, 2)。temperature と top_p のどちらか一方のみを設定してください。詳細については、「テキスト生成モデルの概要」をご参照ください。

top_p 浮動小数点数 (任意)

テキスト多様性を制御する核サンプリングの確率しきい値。値が高いほど多様性が高まり、低いほど決定論的になります。範囲:(0, 1.0]。temperature と top_p のどちらか一方のみを設定してください。詳細については、「テキスト生成モデルの概要」をご参照ください。

enable_thinking ブール値 (任意)

思考モードを有効化します。true の場合、モデルは応答前に思考を行い(思考内容は reasoning 出力項目で返されます)。有効化する場合、複雑なタスクで最良のパフォーマンスを得るために、組み込みツールの有効化を推奨します。

有効な値:

  • true

  • false

モデルごとのデフォルト値:「サポートされるモデル

標準の OpenAI パラメーターではありません。 Python SDK の場合:extra_body={"enable_thinking": True} を使用します。Node.js SDK および curl の場合:enable_thinking: true を最上位のパラメーターとして使用します。

応答オブジェクト(非ストリーミング出力)

{
    "created_at": 1771165900.0,
    "id": "f75c28fb-4064-48ed-90da-4d2cc4362xxx",
    "model": "qwen3.5-plus",
    "object": "response",
    "output": [
        {
            "content": [
                {
                    "annotations": [],
                    "text": "こんにちは!私は Alibaba Cloud が開発した大規模言語モデル Qwen3.5 です。2026 年までの知識を備えており、複雑な推論、創造的なタスク、多言語での会話などを支援するよう設計されています。",
                    "type": "output_text"
                }
            ],
            "id": "msg_89ad23e6-f128-4d4c-b7a1-a786e7880xxx",
            "role": "assistant",
            "status": "completed",
            "type": "message"
        }
    ],
    "parallel_tool_calls": false,
    "status": "completed",
    "tool_choice": "auto",
    "tools": [],
    "usage": {
        "input_tokens": 57,
        "input_tokens_details": {
            "cached_tokens": 0
        },
        "output_tokens": 44,
        "output_tokens_details": {
            "reasoning_tokens": 0
        },
        "total_tokens": 101,
        "x_details": [
            {
                "input_tokens": 57,
                "output_tokens": 44,
                "total_tokens": 101,
                "x_billing_type": "response_api"
            }
        ]
    }
}

id 文字列

固有の応答 ID(有効期限:7 日間)。マルチターン対話で previous_response_id として使用します。

created_at 整数

このリクエストの Unix タイムスタンプ(秒単位)。

object 文字列

オブジェクトタイプ。値は response です。

status 文字列

応答生成のステータス。有効な値:

  • completed

  • failed

  • in_progress

  • cancelled

  • queued

  • incomplete

model 文字列

応答生成に使用されたモデルの ID。

output 配列

モデルによって生成された出力項目。タイプおよび順序はモデルの応答に依存します。

配列要素のプロパティ

type 文字列

出力項目のタイプ。有効な値:

  • message:メッセージタイプ。モデルが生成した最終的な応答本文を含みます。

  • reasoning:思考モード(enable_thinking: true)が有効な場合に返されます。推論トークンは output_tokens_details.reasoning_tokens にカウントされ、課金対象となります。

  • function_call:関数呼び出しタイプ。ユーザー定義の function ツールが使用された場合に返されます。関数呼び出しを処理し、結果を返す必要があります。

  • web_search_call:検索呼び出しタイプ。web_search ツールが使用された場合に返されます。

  • code_interpreter_call:コード実行タイプ。code_interpreter ツールが使用された場合に返されます。

  • web_extractor_call:Web ページ抽出タイプ。web_extractor ツールが使用された場合に返されます。web_search ツールと併用する必要があります。

  • web_search_image_call:テキストによる画像検索呼び出しタイプ。web_search_image ツールが使用された場合に返されます。検索された画像のリストを含みます。

  • image_search_call:画像による画像検索呼び出しタイプ。image_search ツールが使用された場合に返されます。類似画像のリストを含みます。

  • mcp_call:MCP 呼び出しタイプ。mcp ツールが使用された場合に返されます。MCP サービス呼び出しの結果を含みます。

  • file_search_call:ナレッジベース検索呼び出しタイプ。file_search ツールが使用された場合に返されます。ナレッジベースからの検索クエリおよび結果を含みます。

id 文字列

出力項目の固有識別子。すべてのタイプの出力項目に含まれます。

role 文字列

メッセージのロール(値:assistant)。typemessage の場合にのみ存在します。

status 文字列

出力項目のステータス。有効な値:completedin_progresstypemessage の場合に存在します。

name 文字列

ツールまたは関数の名前。typefunction_callweb_search_image_callimage_search_call、または mcp_call の場合に存在します。

web_search_image_call および image_search_call の場合、値はそれぞれ固定で "web_search_image" および "image_search" です。

mcp_call の場合、値は MCP サービスで呼び出された特定の関数名(例:amap-maps-maps_geo)です。

arguments 文字列

ツール呼び出しの引数(JSON 文字列)。function_callweb_search_image_callimage_search_call、または mcp_call の場合に存在します。JSON.parse() を使用して解析してから利用してください。ツールタイプごとの引数:

  • web_search_image_call{"queries": ["検索語 1", "検索語 2"]}queries は、ユーザー入力に基づいてモデルが自動生成した検索語のリスト)。

  • image_search_call{"img_idx": 0, "bbox": [0, 0, 1000, 1000]}img_idx は入力画像のインデックス(0 から始まる)、bbox は検索領域のバウンディングボックス座標 [x1, y1, x2, y2](範囲:0–1000))。

  • function_call:ユーザー定義関数パラメーターのスキーマに従って生成された引数オブジェクト。

  • mcp_call:MCP サービスで呼び出された関数の引数オブジェクト。

call_id 文字列

固有の関数呼び出し識別子。typefunction_call の場合にのみ存在します。結果を返す際にリクエストと応答を関連付けるために使用します。

content 配列

メッセージ本文の配列。typemessage の場合にのみ存在します。

配列要素のプロパティ

type 文字列

コンテンツタイプ。値は output_text です。

text 文字列

モデルが生成したテキスト本文。

annotations 配列

テキストアノテーションの配列。通常は空の配列です。

summary 配列

推論サマリーの配列。typereasoning の場合にのみ存在します。各要素には type フィールド(値:summary_text)および text フィールド(サマリー本文を含む)があります。

action オブジェクト

検索アクション情報。typeweb_search_call の場合にのみ存在します。

プロパティ

query 文字列

検索クエリのキーワード。

type 文字列

検索タイプ。値は search です。

sources 配列

検索ソースのリスト。各要素には type フィールドおよび url フィールドがあります。

code 文字列

モデルが生成および実行したコード。typecode_interpreter_call の場合にのみ存在します。

outputs 配列

コード実行出力の配列。typecode_interpreter_call の場合にのみ存在します。各要素には type フィールド(値:logs)および logs フィールド(コード実行ログを含む)があります。

container_id 文字列

コードインタープリター・コンテナの識別子。typecode_interpreter_call の場合にのみ存在します。同一セッション内の複数のコード実行を関連付けるために使用されます。

goal 文字列

Web ページから抽出する必要がある情報を説明する抽出目標の記述。typeweb_extractor_call の場合にのみ存在します。

output 文字列

ツール呼び出しの出力結果(文字列形式)。

  • typeweb_extractor_call の場合、これは抽出された Web コンテンツの要約です。

  • typeweb_search_image_call または image_search_call の場合、これは画像検索結果の配列を含む JSON 文字列です。各要素には title フィールド(画像タイトル)、url フィールド(画像 URL)、index フィールド(連番)があります。

  • typemcp_call の場合、これは MCP サービスから返された JSON 文字列の結果です。

urls 配列

抽出された Web ページの URL のリスト。typeweb_extractor_call の場合にのみ存在します。

server_label 文字列

MCP サービスラベル。typemcp_call の場合にのみ存在します。この呼び出しで使用された MCP サービスを識別します。

queries 配列

ナレッジベース検索に使用されるクエリのリスト。typefile_search_call の場合にのみ存在します。配列要素は、モデルが生成した検索クエリを表す文字列です。

results 配列

ナレッジベース検索結果の配列。typefile_search_call の場合にのみ存在します。

配列要素のプロパティ

file_id 文字列

一致したドキュメントのファイル ID。

filename 文字列

一致したドキュメントのファイル名。

score 浮動小数点数

一致の関連性スコア(0~1 の範囲)。値が高いほど関連性が高くなります。

text 文字列

一致したドキュメントの内容の一部(スニペット)。

usage オブジェクト

このリクエストのトークン消費量。

プロパティ

input_tokens 整数

入力トークン数。

output_tokens 整数

モデルが出力したトークン数。

total_tokens 整数

消費された合計トークン数(input_tokens + output_tokens)。

input_tokens_details オブジェクト

入力トークンの詳細な分類。

プロパティ

cached_tokens 整数

キャッシュヒットしたトークン数。詳細については、「コンテキストキャッシュ」をご参照ください。

output_tokens_details オブジェクト

出力トークンの詳細な分類。

プロパティ

reasoning_tokens 整数

思考プロセスにおけるトークン数。

x_details オブジェクト

プロパティ

input_tokens 整数

入力トークン数。

output_tokens 整数

モデルが出力したトークン数。

total_tokens 整数

消費された合計トークン数(input_tokens + output_tokens)。

x_billing_type 文字列

値は response_api です。

x_tools オブジェクト

ツール使用統計。組み込みツールの呼び出し回数を含みます。

例:{"web_search": {"count": 1}}

error オブジェクト

失敗時に返されるエラー・オブジェクト(成功時は null)。

tools 配列

リクエストの tools パラメーターをエコーします(リクエストボディと同一の構造)。

tool_choice 文字列

エコーリクエストの tool_choice パラメーターの値。有効な値は autononerequired です。

応答チャンク・オブジェクト(ストリーミング出力)

基本的な呼び出し

// response.created — 応答作成
{"response":{"id":"428c90e9-9cd6-90a6-9726-c02b08ebexxx","created_at":1769082930,"object":"response","status":"queued",...},"sequence_number":0,"type":"response.created"}

// response.in_progress — 応答処理中
{"response":{"id":"428c90e9-9cd6-90a6-9726-c02b08ebexxx","status":"in_progress",...},"sequence_number":1,"type":"response.in_progress"}

// response.output_item.added — 新しい出力項目が追加された
{"item":{"id":"msg_bcb45d66-fc34-46a2-bb56-714a51e8exxx","content":[],"role":"assistant","status":"in_progress","type":"message"},"output_index":0,"sequence_number":2,"type":"response.output_item.added"}

// response.content_part.added — 新しいコンテンツ・ブロックが追加された
{"content_index":0,"item_id":"msg_bcb45d66-fc34-46a2-bb56-714a51e8exxx","output_index":0,"part":{"annotations":[],"text":"","type":"output_text","logprobs":null},"sequence_number":3,"type":"response.content_part.added"}

// response.output_text.delta — 増分テキスト(複数回トリガー)
{"content_index":0,"delta":"人工知能","item_id":"msg_bcb45d66-fc34-46a2-bb56-714a51e8exxx","logprobs":[],"output_index":0,"sequence_number":4,"type":"response.output_text.delta"}
{"content_index":0,"delta":"(AI)とは、コンピューターシステムによって人間の知的行動を模倣する技術および科学を指します","item_id":"msg_bcb45d66-fc34-46a2-bb56-714a51e8exxx","logprobs":[],"output_index":0,"sequence_number":6,"type":"response.output_text.delta"}

// response.output_text.done — テキスト完了
{"content_index":0,"item_id":"msg_bcb45d66-fc34-46a2-bb56-714a51e8exxx","logprobs":[],"output_index":0,"sequence_number":53,"text":"人工知能(AI)とは、コンピューターシステムによって人間の知的行動を模倣する技術および科学を指します…","type":"response.output_text.done"}

// response.content_part.done — コンテンツ・ブロック完了
{"content_index":0,"item_id":"msg_bcb45d66-fc34-46a2-bb56-714a51e8exxx","output_index":0,"part":{"annotations":[],"text":"…完全なテキスト…","type":"output_text","logprobs":null},"sequence_number":54,"type":"response.content_part.done"}

// response.output_item.done — 出力項目完了
{"item":{"id":"msg_bcb45d66-fc34-46a2-bb56-714a51e8exxx","content":[{"annotations":[],"text":"…完全なテキスト…","type":"output_text","logprobs":null}],"role":"assistant","status":"completed","type":"message"},"output_index":0,"sequence_number":55,"type":"response.output_item.done"}

// response.completed — 応答完了(完全な応答および使用量を含む)
{"response":{"id":"428c90e9-9cd6-90a6-9726-c02b08ebexxx","created_at":1769082930,"model":"qwen3-max-2026-01-23","object":"response","output":[...],"status":"completed","usage":{"input_tokens":37,"output_tokens":243,"total_tokens":280,...}},"sequence_number":56,"type":"response.completed"}

Web スクレイピング

id:1
event:response.created
:HTTP_STATUS/200
data:{"sequence_number":0,"type":"response.created","response":{"output":[],"parallel_tool_calls":false,"created_at":1769435906,"tool_choice":"auto","model":"","id":"863df8d9-cb29-4239-a54f-3e15a2427xxx","tools":[],"object":"response","status":"queued"}}

id:2
event:response.in_progress
:HTTP_STATUS/200
data:{"sequence_number":1,"type":"response.in_progress","response":{"output":[],"parallel_tool_calls":false,"created_at":1769435906,"tool_choice":"auto","model":"","id":"863df8d9-cb29-4239-a54f-3e15a2427xxx","tools":[],"object":"response","status":"in_progress"}}

id:3
event:response.output_item.added
:HTTP_STATUS/200
data:{"sequence_number":2,"item":{"summary":[],"type":"reasoning","id":"msg_5bd0c6df-19b8-4a04-bc00-8042a224exxx"},"output_index":0,"type":"response.output_item.added"}

id:4
event:response.reasoning_summary_text.delta
:HTTP_STATUS/200
data:{"delta":"ユーザーの要求は以下の通りです:\n1. Alibaba Cloud の公式ウェブサイトを検索する。\n2. ホームページから主要情報を抽出する。\n\nまず、Alibaba Cloud ウェブサイトの URL を検索し、次に web_extractor ツールを使用してサイトにアクセスして主要情報を抽出する必要があります。","sequence_number":3,"output_index":0,"type":"response.reasoning_summary_text.delta","item_id":"msg_5bd0c6df-19b8-4a04-bc00-8042a224exxx","summary_index":0}

id:14
event:response.reasoning_summary_text.done
:HTTP_STATUS/200
data:{"sequence_number":13,"text":"ユーザーの要求は以下の通りです:\n1. Alibaba Cloud の公式ウェブサイトを検索する。\n2. ホームページから主要情報を抽出する。\n\nまず、Alibaba Cloud ウェブサイトの URL を検索し、次に web_extractor ツールを使用してサイトにアクセスして主要情報を抽出する必要があります。","output_index":0,"type":"response.reasoning_summary_text.done","item_id":"msg_5bd0c6df-19b8-4a04-bc00-8042a224exxx","summary_index":0}

id:15
event:response.output_item.done
:HTTP_STATUS/200
data:{"sequence_number":14,"item":{"summary":[{"type":"summary_text","text":"ユーザーの要求は以下の通りです:\n1. Alibaba Cloud の公式ウェブサイトを検索する。\n2. ホームページから主要情報を抽出する。\n\nまず、Alibaba Cloud ウェブサイトの URL を検索し、次に web_extractor ツールを使用してサイトにアクセスして主要情報を抽出する必要があります。"}],"type":"reasoning","id":"msg_5bd0c6df-19b8-4a04-bc00-8042a224exxx"},"output_index":1,"type":"response.output_item.done"}

id:16
event:response.output_item.added
:HTTP_STATUS/200
data:{"sequence_number":15,"item":{"action":{"type":"search","query":"Web 検索"},"id":"msg_a8a686b1-0a57-40e1-bb55-049a89cd4xxx","type":"web_search_call","status":"in_progress"},"output_index":1,"type":"response.output_item.added"}

id:17
event:response.web_search_call.in_progress
:HTTP_STATUS/200
data:{"sequence_number":16,"output_index":1,"type":"response.web_search_call.in_progress","item_id":"msg_a8a686b1-0a57-40e1-bb55-049a89cd4xxx"}

id:19
event:response.web_search_call.completed
:HTTP_STATUS/200
data:{"sequence_number":18,"output_index":1,"type":"response.web_search_call.completed","item_id":"msg_a8a686b1-0a57-40e1-bb55-049a89cd4xxx"}

id:20
event:response.output_item.done
:HTTP_STATUS/200
data:{"sequence_number":19,"item":{"action":{"sources":[{"type":"url","url":"https://cn.aliyun.com/"},{"type":"url","url":"https://www.aliyun.com/"}],"type":"search","query":"Web 検索"},"id":"msg_a8a686b1-0a57-40e1-bb55-049a89cd4xxx","type":"web_search_call","status":"completed"},"output_index":1,"type":"response.output_item.done"}

id:33
event:response.output_item.added
:HTTP_STATUS/200
data:{"sequence_number":32,"item":{"urls":["https://cn.aliyun.com/"],"goal":"Alibaba Cloud のホームページから以下の情報を抽出:会社のポジショニング/プロファイル、コア製品およびサービス、主なビジネスセクション、特徴的な機能/ソリューション、最新ニュース/イベント、無料トライアル/プロモーション情報、ナビゲーションメニュー構造など。","id":"msg_8c2cf651-48a5-460c-aa7a-bea5b09b4xxx","type":"web_extractor_call","status":"in_progress"},"output_index":3,"type":"response.output_item.added"}

id:34
event:response.output_item.done
:HTTP_STATUS/200
data:{"sequence_number":33,"item":{"output":"https://cn.aliyun.com/ のページから、ユーザーの目的「Alibaba Cloud のホームページから以下の情報を抽出:会社のポジショニング/プロファイル、コア製品およびサービス、主なビジネスセクション、特徴的な機能/ソリューション、最新ニュース/イベント、無料トライアル/プロモーション情報、ナビゲーションメニュー構造など」に関する有用な情報は以下の通りです:\n\nページ内の証拠:\n## Tongyi 大規模モデル — 企業が AI 時代を擁護するための第一選択\n\n## 企業向け技術革新のクラウドを創出する完全な製品システム\n\nすべてのクラウド製品## 大規模モデルとクラウドコンピューティングの連携発展により、AI を誰もが手に入れられるようにする\n\nすべての AI ソリューション\n\n要約:\nAlibaba Cloud は、Tongyi 大規模モデルを中心とした企業向け AI ソリューションプロバイダーとして位置付けられています…","urls":["https://cn.aliyun.com/"],"goal":"Alibaba Cloud のホームページから以下の情報を抽出:会社のポジショニング/プロファイル、コア製品およびサービス、主なビジネスセクション、特徴的な機能/ソリューション、最新ニュース/イベント、無料トライアル/プロモーション情報、ナビゲーションメニュー構造など。","id":"msg_8c2cf651-48a5-460c-aa7a-bea5b09b4xxx","type":"web_extractor_call","status":"completed"},"output_index":3,"type":"response.output_item.done"}

id:50
event:response.output_item.added
:HTTP_STATUS/200
data:{"sequence_number":50,"item":{"content":[{"type":"text","text":""}],"type":"message","id":"msg_final","role":"assistant"},"output_index":5,"type":"response.output_item.added"}

id:51
event:response.output_text.delta
:HTTP_STATUS/200
data:{"delta":"Alibaba Cloud の公式ウェブサイトを検索し、ホームページから主要情報を抽出しました:\n\n","sequence_number":51,"output_index":5,"type":"response.output_text.delta"}

id:60
event:response.completed
:HTTP_STATUS/200
data:{"type":"response.completed","response":{"id":"863df8d9-cb29-4239-a54f-3e15a2427xxx","status":"completed","usage":{"input_tokens":45,"output_tokens":320,"total_tokens":365}}}

テキストによる画像検索

// 1. response.created — 応答作成
id:1
event:response.created
data:{"sequence_number":0,"type":"response.created","response":{"output":[],"status":"queued",...}}

// 2. response.in_progress — 応答処理中
id:2
event:response.in_progress
data:{"sequence_number":1,"type":"response.in_progress","response":{"status":"in_progress",...}}

// 3. response.output_item.added — 推論開始(reasoning)
id:3
event:response.output_item.added
data:{"sequence_number":2,"item":{"summary":[],"type":"reasoning","id":"msg_xxx"},"output_index":0,"type":"response.output_item.added"}

// 4. response.reasoning_summary_text.delta — 推論サマリーの増分
id:4
event:response.reasoning_summary_text.delta
data:{"delta":"ユーザーは猫の画像を探しています。web_search_image ツールを使用して猫の画像を検索する必要があります…","sequence_number":3,"output_index":0,"type":"response.reasoning_summary_text.delta","item_id":"msg_xxx","summary_index":0}

// 5. response.reasoning_summary_text.done — 推論サマリー完了
id:10
event:response.reasoning_summary_text.done
data:{"sequence_number":9,"text":"ユーザーは猫の画像を探しています。web_search_image ツールを使用して猫の画像を検索する必要があります。","output_index":0,"type":"response.reasoning_summary_text.done","item_id":"msg_xxx","summary_index":0}

// 6. response.output_item.done — 推論項目完了
id:11
event:response.output_item.done
data:{"sequence_number":10,"item":{"summary":[{"type":"summary_text","text":"…"}],"type":"reasoning","id":"msg_xxx"},"output_index":0,"type":"response.output_item.done"}

// 7. response.output_item.added — テキストによる画像検索ツール呼び出し開始(status: in_progress、name および arguments を含む)
id:12
event:response.output_item.added
data:{"sequence_number":11,"item":{"name":"web_search_image","arguments":"{\"queries\": [\"猫の画像\", \"かわいい猫\"]}","id":"msg_xxx","type":"web_search_image_call","status":"in_progress"},"output_index":1,"type":"response.output_item.added"}

// 8. response.output_item.done — テキストによる画像検索ツール呼び出し完了(完全な出力検索結果を含む)
id:13
event:response.output_item.done
data:{"sequence_number":12,"item":{"name":"web_search_image","output":"[{\"title\": \"かわいい子猫…\", \"url\": \"https://example.com/cat.jpg\", \"index\": 1}, …]","arguments":"{\"queries\": [\"猫の画像\", \"かわいい猫\"]}","id":"msg_xxx","type":"web_search_image_call","status":"completed"},"output_index":1,"type":"response.output_item.done"}

// 9–12. 第二ラウンドの推論 + 最終メッセージ出力(基本呼び出しと同じ)
// response.output_item.added(reasoning)→ reasoning_summary_text.delta/done → response.output_item.done(reasoning)
// response.output_item.added(message)→ response.content_part.added → response.output_text.delta → response.output_text.done → response.content_part.done → response.output_item.done(message)

// 13. response.completed — 応答完了
id:118
event:response.completed
data:{"sequence_number":117,"type":"response.completed","response":{"output":[...],"status":"completed","usage":{"input_tokens":7895,"output_tokens":318,"total_tokens":8213,"x_tools":{"web_search_image":{"count":1}}}}}

画像検索

// 1–6. 推論フェーズ(テキストによる画像検索と同様)

// 7. response.output_item.added — 画像検索ツール呼び出し開始
// 注:arguments には img_idx(画像インデックス)および bbox(検索領域のバウンディングボックス)が含まれます
id:29
event:response.output_item.added
data:{"sequence_number":29,"item":{"name":"image_search","arguments":"{\"img_idx\": 0, \"bbox\": [0, 0, 1000, 1000]}","id":"msg_xxx","type":"image_search_call","status":"in_progress"},"output_index":1,"type":"response.output_item.added"}

// 8. response.output_item.done — 画像検索ツール呼び出し完了
id:30
event:response.output_item.done
data:{"sequence_number":30,"item":{"name":"image_search","output":"[{\"title\": \"風景の背景…\", \"url\": \"https://example.com/landscape.jpg\", \"index\": 1}, …]","arguments":"{\"img_idx\": 0, \"bbox\": [0, 0, 1000, 1000]}","id":"msg_xxx","type":"image_search_call","status":"completed"},"output_index":1,"type":"response.output_item.done"}

// 9–12. 第二ラウンドの推論 + 最終メッセージ出力(基本呼び出しと同じ)

// 13. response.completed
id:408
event:response.completed
data:{"sequence_number":407,"type":"response.completed","response":{"output":[...],"status":"completed","usage":{"input_tokens":8371,"output_tokens":417,"total_tokens":8788,"x_tools":{"image_search":{"count":1}}}}}

MCP

// 1-6. 推論フェーズ (他のツールと同様)

// 7. response.mcp_call_arguments.delta - MCP 引数デルタ (MCP 固有のイベント)
id:27
event:response.mcp_call_arguments.delta
data:{"delta":"{\"city\": \"Beijing\"}","sequence_number":26,"output_index":1,"type":"response.mcp_call_arguments.delta","item_id":"msg_xxx"}

// 8. response.mcp_call_arguments.done - MCP 引数完了 (MCP 固有のイベント)
id:28
event:response.mcp_call_arguments.done
data:{"sequence_number":27,"arguments":"{\"city\": \"Beijing\"}","output_index":1,"type":"response.mcp_call_arguments.done","item_id":"msg_xxx"}

// 9. response.output_item.added - MCP ツール呼び出し開始 (名前、サーバーラベル、引数を含む)
id:29
event:response.output_item.added
data:{"sequence_number":28,"item":{"name":"amap-maps-maps_weather","server_label":"MCP Server","arguments":"{\"city\": \"Beijing\"}","id":"msg_xxx","type":"mcp_call","status":"in_progress"},"output_index":1,"type":"response.output_item.added"}

// 10. response.mcp_call.completed - MCP 呼び出し完了 (MCP 固有のイベント)
id:30
event:response.mcp_call.completed
data:{"sequence_number":29,"output_index":1,"type":"response.mcp_call.completed","item_id":"msg_xxx"}

// 11. response.output_item.done - MCP 出力アイテム完了 (完全な出力を含む)
id:31
event:response.output_item.done
data:{"sequence_number":30,"item":{"output":"{\"city\":\"Beijing\",\"forecasts\":[...]}","name":"amap-maps-maps_weather","server_label":"MCP Server","arguments":"{\"city\": \"Beijing\"}","id":"msg_xxx","type":"mcp_call","status":"completed"},"output_index":1,"type":"response.output_item.done"}

// 12-15. 2 回目の推論 + 最終メッセージ出力

// 16. response.completed
id:172
event:response.completed
data:{"sequence_number":171,"type":"response.completed","response":{"output":[...],"status":"completed","usage":{"input_tokens":5019,"output_tokens":539,"total_tokens":5558}}}

ナレッジベース検索

// 1–6. 推論フェーズ(他のツールと同様)

// 7. response.output_item.added — ナレッジベース検索開始(queries を含み、結果は未定義)
id:19
event:response.output_item.added
data:{"sequence_number":18,"item":{"id":"msg_xxx","type":"file_search_call","queries":["Alibaba Cloud Bailian X1 電話","Alibaba Cloud Bailian X1 電話","Bailian X1"],"status":"in_progress"},"output_index":1,"type":"response.output_item.added"}

// 8. response.file_search_call.in_progress — 検索処理中(file_search 固有のイベント)
id:20
event:response.file_search_call.in_progress
data:{"sequence_number":19,"output_index":1,"type":"response.file_search_call.in_progress","item_id":"msg_xxx"}

// 9. response.file_search_call.searching — 検索中(file_search 固有のイベント)
id:21
event:response.file_search_call.searching
data:{"sequence_number":20,"output_index":1,"type":"response.file_search_call.searching","item_id":"msg_xxx"}

// 10. response.file_search_call.completed — 検索完了(file_search 固有のイベント)
id:22
event:response.file_search_call.completed
data:{"sequence_number":21,"output_index":1,"type":"response.file_search_call.completed","item_id":"msg_xxx"}

// 11. response.output_item.done — 出力項目完了(queries + 結果を含む)
id:23
event:response.output_item.done
data:{"sequence_number":22,"item":{"id":"msg_xxx","type":"file_search_call","queries":["Alibaba Cloud Bailian X1 電話","Alibaba Cloud Bailian X1 電話","Bailian X1"],"results":[{"score":0.7519,"filename":"Alibaba Cloud Bailian シリーズ電話機の紹介","text":"Alibaba Cloud Bailian X1 — 最高の視覚体験をお楽しみください…","file_id":"file_xxx"}],"status":"completed"},"output_index":1,"type":"response.output_item.done"}

// 12–15. 第二ラウンドの推論 + 最終メッセージ出力

// 16. response.completed
id:146
event:response.completed
data:{"sequence_number":145,"type":"response.completed","response":{"output":[...],"status":"completed","usage":{"input_tokens":1576,"output_tokens":722,"total_tokens":2298,"x_tools":{"file_search":{"count":1}}}}}

ストリーミングでは、type(イベントタイプ)および sequence_number(イベント順序)を含む JSON オブジェクトが返されます。response.completed イベントでストリームが終了します。

type 文字列

イベントタイプ識別子。有効な値:

  • response.created:応答作成(ステータス:queued)。

  • response.in_progress:処理開始(ステータス:in_progress)。

  • response.output_item.added:新しい出力項目が追加された(message、web_extractor_call など)。item.typeweb_extractor_call の場合、ツール呼び出しが開始されています。

  • response.content_part.added:出力項目に新しいコンテンツ・ブロックが追加された。

  • response.output_text.delta:増分テキスト生成(複数回トリガー)。delta フィールドには新しいテキスト断片が含まれます。

  • response.output_text.done:テキスト生成完了。text フィールドには完全なテキストが含まれます。

  • response.content_part.done:コンテンツ・ブロック完了。part オブジェクトには完全なブロックが含まれます。

  • response.output_item.done:出力項目生成完了。item オブジェクトには完全な項目が含まれます。item.typeweb_extractor_call の場合、ツール呼び出しが完了しています。

  • response.reasoning_summary_text.delta:(思考モード)増分推論サマリー・テキスト。delta フィールドには新しい断片が含まれます。

  • response.reasoning_summary_text.done:(思考モード)推論サマリー完了。text フィールドには完全なサマリーが含まれます。

  • response.web_search_call.in_progress / searching / completed:(web_search ツールを使用する場合)検索ステータス変更イベント。

  • response.code_interpreter_call.in_progress / interpreting / completed:(code_interpreter ツールを使用する場合)コード実行ステータス変更イベント。

  • 注: web_extractor ツールには専用のイベントタイプはありません。ツール呼び出しには response.output_item.added および response.output_item.done イベント(item.type = web_extractor_call で識別)が使用されます。

  • response.mcp_call_arguments.delta / response.mcp_call_arguments.done:(mcp ツールを使用する場合)MCP 呼び出し引数の増分および完了イベント。

  • response.mcp_call.completed:(mcp ツールを使用する場合)MCP サービス呼び出し完了。

  • response.file_search_call.in_progress / searching / completed:(file_search ツールを使用する場合)ナレッジベース検索ステータス変更イベント。

  • 注: web_search_image および image_search ツールには中間状態イベントはありません。ツール呼び出しには response.output_item.added(開始)および response.output_item.done(完了)が使用されます。

  • response.completed:応答生成完了。response オブジェクトには完全な応答および使用量情報が含まれます。ストリーム終了を示します。

sequence_number 整数

イベントのシリアル番号(0 から始まり、インクリメント)。クライアント側での正しいイベント処理順序を保証するために使用します。

response オブジェクト

応答オブジェクト(response.createdresponse.in_progressresponse.completed で出現)。response.completed では、完全なデータ(outputusage)を含みます。非ストリーミング応答の構造と一致します。

item オブジェクト

出力項目オブジェクト(response.output_item.addedresponse.output_item.done で出現)。added の場合:空の content 配列を持つスケルトン。done の場合:完全なオブジェクト。

プロパティ

id 文字列

出力項目の固有識別子(例:msg_xxx)。

type 文字列

出力項目のタイプ。有効な値:messagereasoningweb_search_call(検索)、web_search_image_call(テキストによる画像検索)、image_search_call(画像による画像検索)、mcp_call、および file_search_call(ナレッジベース検索)。

role 文字列

メッセージのロール。値は assistant です。message の場合にのみ存在します。

status 文字列

生成ステータス:added イベントでは in_progressdone イベントでは completed

content 配列

メッセージ本文の配列。added の場合:空の []done の場合:完全なコンテンツ・ブロック(part と同じ構造)。

part オブジェクト

コンテンツ・ブロック・オブジェクト。response.content_part.added および response.content_part.done イベントで出現します。

プロパティ

type 文字列

コンテンツ・ブロックのタイプ。値は output_text です。

text 文字列

テキスト内容:added の場合:空文字列、done の場合:完全なテキスト。

annotations 配列

テキストアノテーションの配列。通常は空の配列です。

logprobs オブジェクト | null

トークンの対数確率情報。現在は null です。

delta 文字列

response.output_text.delta イベントにおける増分テキスト内容(新しい断片を含む)。完全なテキストを得るには、すべての delta 断片を連結します。

text 文字列

response.output_text.done イベントにおける完全なテキスト内容。連結した delta 結果を検証するために使用します。

item_id 文字列

出力項目の固有識別子。同じ出力項目に関連するイベントを関連付けるために使用します。

output_index 整数

output 配列内での出力項目のインデックス位置。

content_index 整数

content 配列内でのコンテンツ・ブロックのインデックス位置。

summary_index 整数

サマリー配列のインデックス。これは response.reasoning_summary_text.delta および response.reasoning_summary_text.done イベントで出現します。

よくある質問

Q:マルチターン対話のコンテキストを渡すにはどうすればよいですか?

A:idprevious_response_id パラメーターとして渡します。

Q:応答のサンプルで説明されていないフィールドがありますが、その理由は何ですか?

A:公式 OpenAI SDK は、そのモデル構造に基づいて追加のフィールド(通常は null)を出力することがあります。これらは OpenAI プロトコルで定義されていますが、現時点ではサポートされていません。ドキュメント化されたフィールドのみに着目してください。