Skip to main content

サーバーサイドイベント

このトピックでは、Qwen-TTS-Realtime API のサーバーサイドイベントについて説明します。

詳細については、「Qwen を使用したリアルタイム音声合成」をご参照ください。

error

サーバーは、クライアントサイドとサーバーサイドの両方のエラーに対してこのイベントに応答します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に error です。errorobjectエラー詳細です。

プロパティ

codestringエラーコードです。messagestringエラーメッセージです。
{
  "event_id": "event_QzAVZRVa9hKqM5VOaHunh",
  "type": "error",
  "error": {
    "code": "invalid_value",
    "message": "Session update error: session already started or finished or failed."
  }
}

session.created

クライアントが接続した後、サーバーは最初の応答としてこのイベントを送信します。これには、セッションのデフォルト構成が含まれます。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に session.created です。sessionobjectセッション構成です。

プロパティ

idstringセッション ID です。objectstringセッションサービス名です。modestringインタラクションモードです。有効な値は server_commit または commit です。modelstring使用されるモデルです。voicestring使用される音声です。response_formatstringオーディオフォーマットです。sample_rateinteger音声サンプリングレートです。
{
  "event_id": "event_xxx",
  "type": "session.created",
  "session": {
    "object": "realtime.session",
    "mode": "server_commit",
    "model": "qwen3-tts-flash-realtime",
    "voice": "Cherry",
    "response_format": "pcm",
    "sample_rate": 24000,
    "id": "sess_xxx"
  }
}

session.updated

サーバーは、クライアントから session.update リクエストを受信して正常に処理した後に、このイベントを送信します。エラーが発生した場合は、代わりに error イベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に session.updated です。sessionobjectセッション構成です。

プロパティ

idstringセッション ID です。objectstringセッションサービス名です。modestringインタラクションモードです。有効な値は server_commit または commit です。modelstring使用されるモデルです。voicestring使用される音色です。response_formatstringオーディオフォーマットです。sample_rateinteger音声サンプリングレートです。language_typestringオーディオの言語です。
{
  "event_id": "event_xxx",
  "type": "session.updated",
  "session": {
    "id": "sess_xxx",
    "object": "realtime.session",
    "model": "qwen3-tts-flash-realtime",
    "voice": "Cherry",
    "language_type": "Chinese",
    "mode": "commit",
    "response_format": "pcm",
    "sample_rate": 24000
  }
}

input_text_buffer.committed

クライアントから input_text_buffer.commit イベントを受信した後、サーバーはこのイベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に input_text_buffer.committed です。item_idstring作成するユーザーメッセージアイテムの ID です。
{
  "event_id": "event_FC6MA88wS2oEeXkPvWsxX",
  "type": "input_text_buffer.committed",
  "item_id": ""
}

input_text_buffer.cleared

クライアントが input_audio_buffer.clear イベントを送信した後のサーバーの応答イベントです。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に input_text_buffer.cleared です。
{
    "event_id": "event_1122",
    "type": "input_text_buffer.cleared"
}

response.created

クライアントから input_text_buffer.commit イベントを受信した後、サーバーはこのイベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に response.created です。responseobject応答詳細です。

プロパティ

idstring応答 ID です。objectstringオブジェクトタイプです。この値は常に realtime.response です。statusstring応答の最終ステータスです。有効な値は次のとおりです。
  • completed
  • failed
  • in_progress
  • incomplete
voicestring使用される音声です。outputarrayこのフィールドは、このイベントでは空です。
{
  "event_id": "event_IMnLqDvG6Ahhk7sWV2uOs",
  "type": "response.created",
  "response": {
    "id": "resp_USvBwHktHcz76r6GaIJUV",
    "object": "realtime.response",
    "conversation_id": "",
    "status": "in_progress",
    "voice": "Cherry",
    "output": []
  }
}

response.output_item.added

新しい出力アイテムの準備ができたときに、サーバーはこのイベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に response.output_item.added です。response_idstring応答の ID です。output_indexinteger応答出力アイテムのインデックスです。この値は常に 0 です。itemobject出力アイテム詳細です。

プロパティ

idstring出力アイテムの ID です。objectstringこの値は常に realtime.item です。statusstring出力アイテムのステータスです。contentarrayメッセージコンテンツです。
{
  "event_id": "event_INDGnGNulaXCrStd9ZM5X",
  "type": "response.output_item.added",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "output_index": 0,
  "item": {
    "id": "item_FIrYGaNVK3rbIZqeY4QjM",
    "object": "realtime.item",
    "type": "message",
    "status": "in_progress",
    "role": "assistant",
    "content": []
  }
}

response.content_part.added

新しいコンテンツパートの準備ができたときに、サーバーはこのイベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に response.content_part.added です。response_idstring応答の ID です。item_idstringメッセージアイテムの ID です。output_indexinteger応答出力アイテムのインデックスです。この値は常に 0 です。content_indexinteger応答出力アイテム内のコンテンツパートのインデックスです。この値は常に 0 です。partobject完了したコンテンツパートです。

プロパティ

typestringコンテンツパートのタイプです。textstringコンテンツパートのテキストです。
{
  "event_id": "event_DigZ95MWN36YYyyjcENoq",
  "type": "response.content_part.added",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "item_id": "item_FIrYGaNVK3rbIZqeY4QjM",
  "output_index": 0,
  "content_index": 0,
  "part": {
    "type": "audio",
    "text": ""
  }
}

response.audio.delta

モデルが新しいオーディオデータを増分的に生成するときに、サーバーはこのイベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に response.audio.delta です。response_idstring応答の ID です。item_idstringメッセージアイテムの ID です。output_indexinteger応答出力アイテムのインデックスです。この値は常に 0 です。content_indexinteger応答出力アイテム内のコンテンツパートのインデックスです。この値は常に 0 です。deltastringモデルによって増分的に生成されたオーディオデータです。データは Base64エンコードされています。
{
  "event_id": "event_B1osWMZBtrEQbiIwW0qHQ",
  "type": "response.audio.delta",
  "response_id": "resp_B1osWTzBb8hO0WsELHgVP",
  "item_id": "item_B1osWH81fXDoyim1T5fsF",
  "output_index": 0,
  "content_index": 0,
  "delta": "base64 audio"
}

response.content_part.done

コンテンツパートが完了したときに、サーバーはこのイベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に response.content_part.done です。response_idstring応答の ID です。item_idstringメッセージアイテムの ID です。output_indexinteger応答出力アイテムのインデックスです。この値は常に 0 です。content_indexinteger応答出力アイテム内のコンテンツパートのインデックスです。この値は常に 0 です。partobject完了したコンテンツパートです。

プロパティ

typestringコンテンツパートのタイプです。textstringコンテンツパートのテキストです。
{
  "event_id": "event_Vo2YUjlYQJ4colH8nVzkU",
  "type": "response.content_part.done",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "item_id": "item_FIrYGaNVK3rbIZqeY4QjM",
  "output_index": 0,
  "content_index": 0,
  "part": {
    "type": "audio",
    "text": ""
  }
}

response.output_item.done

出力アイテムが完了したときに、サーバーはこのイベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に response.output_item.done です。response_idstring応答の ID です。output_indexinteger応答出力アイテムのインデックスです。この値は常に 0 です。itemobject出力アイテム詳細です。

プロパティ

idstring出力アイテムの ID です。objectstringこの値は常に realtime.item です。statusstring出力アイテムのステータスです。contentarrayメッセージコンテンツです。
{
  "event_id": "event_LO6SJRKIQ9NBayyYB8a1A",
  "type": "response.output_item.done",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "output_index": 0,
  "item": {
    "id": "item_FIrYGaNVK3rbIZqeY4QjM",
    "object": "realtime.item",
    "type": "message",
    "status": "completed",
    "role": "assistant",
    "content": [
      {
        "type": "audio",
        "text": ""
      }
    ]
  }
}

response.audio.done

モデルがオーディオデータの生成を完了したときに、サーバーはこのイベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に response.audio.done です。response_idstring応答の ID です。item_idstringメッセージアイテムの ID です。output_indexinteger応答出力アイテムのインデックスです。この値は常に 0 です。content_indexinteger応答出力アイテム内のコンテンツパートのインデックスです。この値は常に 0 です。
{
  "event_id": "event_LZaOHPzXYMUXGBcVkBmKX",
  "type": "response.audio.done",
  "response_id": "resp_USvBwHktHcz76r6GaIJUV",
  "item_id": "item_FIrYGaNVK3rbIZqeY4QjM",
  "output_index": 0,
  "content_index": 0
}

response.done

応答生成が完了したときに、サーバーはこのイベントを送信します。このイベントの response オブジェクトには、すべての出力アイテムが含まれますが、すでに送信された生オーディオデータは除外されます。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に response.done です。response_idstring応答の ID です。responseobject応答詳細です。

プロパティ

idstring応答 ID です。objectstringオブジェクトタイプです。この値は常に realtime.response です。outputarray応答出力です。usageobjectこの音声合成リクエストの課金情報です。

プロパティ

charactersintegerQwen3-TTS Realtime で課金される文字数です。
{
    "event_id": "event_Aemy83XqHFFDDSeJIDn6N",
    "type": "response.done",
    "response": {
        "id": "resp_LFeR42yXZ9SxUAeXjmyTz",
        "object": "realtime.response",
        "conversation_id": "",
        "status": "completed",
        "modalities": [
            "text",
            "audio"
        ],
        "voice": "Cherry",
        "output": [
            {
                "id": "item_Ae1lv2XmRljRSG96L8Zm1",
                "object": "realtime.item",
                "type": "message",
                "status": "completed",
                "role": "assistant",
                "content": [
                    {
                        "type": "audio",
                        "transcript": ""
                    }
                ]
            }
        ],
        "usage": {
            "characters": 25
        }
    }
}

session.finished

すべての応答が生成されたときに、サーバーはこのイベントを送信します。
event_idstringサーバーサイドイベントの ID です。typestringイベントタイプです。この値は常に session.finished です。
{
  "event_id": "event_2239",
  "type": "session.finished"
}