{
  "aboutHtml": "<p>Qwen-Audio-3.0-Realtime-Plusは、リアルタイム音声対話のためのAlibabaのモデルです。音声とテキストを受け取り、音声とテキストで応答し、自然なやり取りによる双方向の会話に対応します。音声は分割して送受信できるため、会話の進行中にやり取りを続けられます。</p><h4>相手が話し終えたタイミング</h4><p>発話の区切りを判断する方法として、音声の活動、意味上の完結、明示的な制御が用意されています。メーカーでは、最初の音声を送る前にモードを選択し、会話の開始後に変更するには新しい接続が必要です。この制御への対応は、選択したメソッドによって決まります。意味を考慮するモードでは、間や言いよどみも判断材料にするため、短いためらいが必ずしもユーザーの話の終わりを意味しません。ユーザーが新たに話し始めると、生成中の応答を中断し、次の発話を踏まえて会話を続けられます。意味を考慮するモードでは、選択した相手の音声サンプルを認識の手掛かりにし、他の人の声や背景の雑音に気を取られにくくすることもできます。</p><p>指示はアシスタントの役割や会話のスタイルを定めます。音声表現にはトーン、速度、感情を反映でき、バージョン3.0には五つのシステム音声と、音声サンプルに基づく声が用意されています。モデルはロシア語を含む11言語と、メーカーが指定する中国語の方言に対応しています。メーカーでは、最初のセッション設定更新時に声を指定し、同じ会話で後から新しい声を送っても無視されます。これらの設定には、選択したアクセス方法での対応が必要です。</p><h4>ツールと会話履歴</h4><p>関数呼び出しに対応しています。モデルが必要な動作を提示し、接続されたアプリケーションが実行して結果を会話に返します。実際のデータに基づいて会話を組み立て、処理の実行後も続けられます。音声アシスタントは、会話の文脈を保ちながらツールの結果を利用できます。メーカーの機能には、選択したメソッドで提供される場合の組み込みウェブ検索も含まれます。ウェブ検索と関数呼び出しは、同じセッションで同時に有効にできません。</p><p>既定では会話履歴を20ターン保持し、一ターンから50ターンまで設定できます。蓄積した音声の上限は300秒で、制限を超えると古い履歴が削除されます。これは個々の発話の長さとは異なります。履歴は、会話を続ける際に以前のどの素材を利用できるかを決めます。</p><h4>テキストのコンテキストと音声</h4><p>公称コンテキストは40 960トークンです。入力の最大長は16 384トークン、出力は8192トークンです。推論モードにも同じ入力と出力の上限が示されており、推論の連鎖には別途1024トークンの上限があります。</p><p>ストリーミング音声には、16ビットのモノラルPCMを使用し、入力は16キロヘルツ、出力は24キロヘルツです。テキストと音声のデータは同じ会話に属します。このモデルについて、視覚的な入力や画像の出力は公表されていません。専門領域は発話、テキスト、音声によるやり取りです。</p>",
  "aboutText": "Qwen-Audio-3.0-Realtime-Plusは、リアルタイム音声対話のためのAlibabaのモデルです。音声とテキストを受け取り、音声とテキストで応答し、自然なやり取りによる双方向の会話に対応します。音声は分割して送受信できるため、会話の進行中にやり取りを続けられます。\n\n### 相手が話し終えたタイミング\n\n発話の区切りを判断する方法として、音声の活動、意味上の完結、明示的な制御が用意されています。メーカーでは、最初の音声を送る前にモードを選択し、会話の開始後に変更するには新しい接続が必要です。この制御への対応は、選択したメソッドによって決まります。意味を考慮するモードでは、間や言いよどみも判断材料にするため、短いためらいが必ずしもユーザーの話の終わりを意味しません。ユーザーが新たに話し始めると、生成中の応答を中断し、次の発話を踏まえて会話を続けられます。意味を考慮するモードでは、選択した相手の音声サンプルを認識の手掛かりにし、他の人の声や背景の雑音に気を取られにくくすることもできます。\n\n指示はアシスタントの役割や会話のスタイルを定めます。音声表現にはトーン、速度、感情を反映でき、バージョン3.0には五つのシステム音声と、音声サンプルに基づく声が用意されています。モデルはロシア語を含む11言語と、メーカーが指定する中国語の方言に対応しています。メーカーでは、最初のセッション設定更新時に声を指定し、同じ会話で後から新しい声を送っても無視されます。これらの設定には、選択したアクセス方法での対応が必要です。\n\n### ツールと会話履歴\n\n関数呼び出しに対応しています。モデルが必要な動作を提示し、接続されたアプリケーションが実行して結果を会話に返します。実際のデータに基づいて会話を組み立て、処理の実行後も続けられます。音声アシスタントは、会話の文脈を保ちながらツールの結果を利用できます。メーカーの機能には、選択したメソッドで提供される場合の組み込みウェブ検索も含まれます。ウェブ検索と関数呼び出しは、同じセッションで同時に有効にできません。\n\n既定では会話履歴を20ターン保持し、一ターンから50ターンまで設定できます。蓄積した音声の上限は300秒で、制限を超えると古い履歴が削除されます。これは個々の発話の長さとは異なります。履歴は、会話を続ける際に以前のどの素材を利用できるかを決めます。\n\n### テキストのコンテキストと音声\n\n公称コンテキストは40 960トークンです。入力の最大長は16 384トークン、出力は8192トークンです。推論モードにも同じ入力と出力の上限が示されており、推論の連鎖には別途1024トークンの上限があります。\n\nストリーミング音声には、16ビットのモノラルPCMを使用し、入力は16キロヘルツ、出力は24キロヘルツです。テキストと音声のデータは同じ会話に属します。このモデルについて、視覚的な入力や画像の出力は公表されていません。専門領域は発話、テキスト、音声によるやり取りです。",
  "editorialOverlay": {
    "copy_fields": null,
    "copy_sha256": null,
    "copy_source": null,
    "html_sha256": "9228bdf861abaa6dc0d3fc7f8c4a18700db4fb6549c6d2d7b99e1f4a44412bc8",
    "module_sha256": "ee9dc1c50b1e6a8fb7fa062030fcb4646b9aaaeb08be513b723a5a92a7290f06",
    "raw_model_unchanged": true,
    "schema": "ailoot-native-model-editorial-v1"
  },
  "locale": "ja",
  "methods": [
    {
      "html": "<div class=\"sheet-head\"><span class=\"mav\" aria-hidden=\"true\">Al</span><h2 id=\"sheet-title\">qwen-audio-3.0-realtime-plus</h2><button class=\"icon-btn\" type=\"button\" data-close-sheet aria-label=\"閉じる\">×</button></div><div class=\"idline\"><span>Alibaba /</span><code>qwen-audio-3.0-realtime-plus</code><button type=\"button\" id=\"copy-id\">IDをコピー</button></div><nav class=\"card-jump-nav\" aria-label=\"モデルカードのセクション\"><button type=\"button\" data-card-jump=\"overview\">はじめに</button><button type=\"button\" data-card-jump=\"methods\">入力とメソッド</button><button type=\"button\" data-card-jump=\"pricing\">料金</button><button type=\"button\" data-card-jump=\"examples\">例</button><button type=\"button\" data-card-jump=\"results\">結果</button><button type=\"button\" data-card-jump=\"aliases\">エイリアス</button></nav><div class=\"card-method-tabs\" role=\"tablist\" aria-label=\"APIメソッド\"><button type=\"button\" role=\"tab\" tabindex=\"0\" aria-controls=\"card-method-content\" aria-selected=\"true\" id=\"card-method-tab-0\" data-card-method=\"Core|realtime|/v1/realtime?model=qwen-audio-3.0-realtime-plus|qwen-audio-3.0-realtime-plus\">リアルタイム</button></div><div id=\"card-method-content\" role=\"tabpanel\" aria-labelledby=\"card-method-tab-0\"><section class=\"card-section\" data-card-section=\"overview\"><h3 tabindex=\"-1\">はじめに</h3><p class=\"mdesc-full\">音声とテキストを受け取り、音声またはテキストで応答するリアルタイム音声対話モデルです。自然な会話のテンポとツールとの連携を想定しています。</p><dl class=\"card-io\" data-card-io><div><dt>対応する入力</dt><dd>テキスト · 音声</dd></div><div><dt>結果</dt><dd>テキスト · 音声</dd></div></dl><details class=\"card-about\"><summary>モデルについて</summary><p class=\"note-s\" data-model-method-boundary>この説明はモデルの機能を紹介するものです。Ailootで利用できる入力、出力、オプションは、選択したメソッドごとに以下に記載されています。</p><div class=\"mabout\" id=\"m-about\"><p>Qwen-Audio-3.0-Realtime-Plusは、リアルタイム音声対話のためのAlibabaのモデルです。音声とテキストを受け取り、音声とテキストで応答し、自然なやり取りによる双方向の会話に対応します。音声は分割して送受信できるため、会話の進行中にやり取りを続けられます。</p><h4>相手が話し終えたタイミング</h4><p>発話の区切りを判断する方法として、音声の活動、意味上の完結、明示的な制御が用意されています。メーカーでは、最初の音声を送る前にモードを選択し、会話の開始後に変更するには新しい接続が必要です。この制御への対応は、選択したメソッドによって決まります。意味を考慮するモードでは、間や言いよどみも判断材料にするため、短いためらいが必ずしもユーザーの話の終わりを意味しません。ユーザーが新たに話し始めると、生成中の応答を中断し、次の発話を踏まえて会話を続けられます。意味を考慮するモードでは、選択した相手の音声サンプルを認識の手掛かりにし、他の人の声や背景の雑音に気を取られにくくすることもできます。</p><p>指示はアシスタントの役割や会話のスタイルを定めます。音声表現にはトーン、速度、感情を反映でき、バージョン3.0には五つのシステム音声と、音声サンプルに基づく声が用意されています。モデルはロシア語を含む11言語と、メーカーが指定する中国語の方言に対応しています。メーカーでは、最初のセッション設定更新時に声を指定し、同じ会話で後から新しい声を送っても無視されます。これらの設定には、選択したアクセス方法での対応が必要です。</p><h4>ツールと会話履歴</h4><p>関数呼び出しに対応しています。モデルが必要な動作を提示し、接続されたアプリケーションが実行して結果を会話に返します。実際のデータに基づいて会話を組み立て、処理の実行後も続けられます。音声アシスタントは、会話の文脈を保ちながらツールの結果を利用できます。メーカーの機能には、選択したメソッドで提供される場合の組み込みウェブ検索も含まれます。ウェブ検索と関数呼び出しは、同じセッションで同時に有効にできません。</p><p>既定では会話履歴を20ターン保持し、一ターンから50ターンまで設定できます。蓄積した音声の上限は300秒で、制限を超えると古い履歴が削除されます。これは個々の発話の長さとは異なります。履歴は、会話を続ける際に以前のどの素材を利用できるかを決めます。</p><h4>テキストのコンテキストと音声</h4><p>公称コンテキストは40 960トークンです。入力の最大長は16 384トークン、出力は8192トークンです。推論モードにも同じ入力と出力の上限が示されており、推論の連鎖には別途1024トークンの上限があります。</p><p>ストリーミング音声には、16ビットのモノラルPCMを使用し、入力は16キロヘルツ、出力は24キロヘルツです。テキストと音声のデータは同じ会話に属します。このモデルについて、視覚的な入力や画像の出力は公表されていません。専門領域は発話、テキスト、音声によるやり取りです。</p></div></details></section><section class=\"card-section\" data-card-section=\"methods\"><h3 tabindex=\"-1\">Ailootで利用可能 · 入力とメソッド</h3><details class=\"card-method\" open><summary><b>Ailoot · リアルタイム音声</b> <code>GET /v1/realtime?model=qwen-audio-3.0-realtime-plus</code></summary><dl class=\"method-capabilities\"><div><dt>入力の種類</dt><dd><code>text</code>, <code>audio</code></dd></div><div><dt>出力の種類</dt><dd><code>text</code>, <code>audio</code></dd></div><div><dt>出力形式</dt><dd>セッションイベント</dd></div></dl><div class=\"tw\" data-card-parameters data-typed-parameters><table><thead><tr><th>フィールド</th><th>種類</th><th>要件</th><th>値と制限</th><th>デフォルト</th></tr></thead><tbody><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"フィールド\" scope=\"row\"><span class=\"card-cell-label\">フィールド</span><code class=\"card-field-name\">query.model</code></th><td data-cell-label=\"種類\" data-field-type><span class=\"card-cell-label\">種類</span><code>string</code></td><td data-cell-label=\"要件\"><span class=\"card-cell-label\">要件</span>必須</td><td data-cell-label=\"値と制限\"><span class=\"card-cell-label\">値と制限</span><div>qwen-audio-3.0-realtime-plus</div></td><td data-cell-label=\"デフォルト\" data-default=\"unspecified\"><span class=\"card-cell-label\">デフォルト</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"フィールド\" scope=\"row\"><span class=\"card-cell-label\">フィールド</span><code class=\"card-field-name\">session.input_audio_format</code></th><td data-cell-label=\"種類\" data-field-type><span class=\"card-cell-label\">種類</span><code>string</code></td><td data-cell-label=\"要件\"><span class=\"card-cell-label\">要件</span>任意</td><td data-cell-label=\"値と制限\"><span class=\"card-cell-label\">値と制限</span><div>pcm16, pcm</div></td><td data-cell-label=\"デフォルト\" data-default=\"unspecified\"><span class=\"card-cell-label\">デフォルト</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"フィールド\" scope=\"row\"><span class=\"card-cell-label\">フィールド</span><code class=\"card-field-name\">session.output_audio_format</code></th><td data-cell-label=\"種類\" data-field-type><span class=\"card-cell-label\">種類</span><code>string</code></td><td data-cell-label=\"要件\"><span class=\"card-cell-label\">要件</span>任意</td><td data-cell-label=\"値と制限\"><span class=\"card-cell-label\">値と制限</span><div>pcm16, pcm</div></td><td data-cell-label=\"デフォルト\" data-default=\"unspecified\"><span class=\"card-cell-label\">デフォルト</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"フィールド\" scope=\"row\"><span class=\"card-cell-label\">フィールド</span><code class=\"card-field-name\">session.instructions</code></th><td data-cell-label=\"種類\" data-field-type><span class=\"card-cell-label\">種類</span><code>string</code></td><td data-cell-label=\"要件\"><span class=\"card-cell-label\">要件</span>任意</td><td data-cell-label=\"値と制限\"><span class=\"card-cell-label\">値と制限</span><div>制限の適用対象: 選択したセッションポリシー</div></td><td data-cell-label=\"デフォルト\" data-default=\"unspecified\"><span class=\"card-cell-label\">デフォルト</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"フィールド\" scope=\"row\"><span class=\"card-cell-label\">フィールド</span><code class=\"card-field-name\">session.max_history_turns</code></th><td data-cell-label=\"種類\" data-field-type><span class=\"card-cell-label\">種類</span><code>integer</code></td><td data-cell-label=\"要件\"><span class=\"card-cell-label\">要件</span>任意</td><td data-cell-label=\"値と制限\"><span class=\"card-cell-label\">値と制限</span><div>最小値: 1</div><div>制限の適用対象: 選択したセッションポリシー</div></td><td data-cell-label=\"デフォルト\" data-default=\"unspecified\"><span class=\"card-cell-label\">デフォルト</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"フィールド\" scope=\"row\"><span class=\"card-cell-label\">フィールド</span><code class=\"card-field-name\">input_audio_buffer.append.audio</code></th><td data-cell-label=\"種類\" data-field-type><span class=\"card-cell-label\">種類</span><code>base64_string</code></td><td data-cell-label=\"要件\"><span class=\"card-cell-label\">要件</span>必須</td><td data-cell-label=\"値と制限\"><span class=\"card-cell-label\">値と制限</span><div>入力コンテンツ: PCM16モノラル。入力16 kHz、出力24 kHz。空でなく、バイト長が偶数である必要があります</div></td><td data-cell-label=\"デフォルト\" data-default=\"unspecified\"><span class=\"card-cell-label\">デフォルト</span>—</td></tr></tbody></table></div><details class=\"card-about\" data-material-combinations><summary>入力素材の組み合わせ</summary><p class=\"note-s\"><b>realtime_text_audio</b></p></details><details class=\"note-s\" data-method-contract><summary>メソッドのパラメータとライフサイクル</summary><div class=\"tw\" data-card-table=\"contract\"><table><thead><tr><th>パラメータ</th><th>仕様</th></tr></thead><tbody><tr><th data-cell-label=\"パラメータ\" scope=\"row\"><span class=\"card-cell-label\">パラメータ</span><code>material_types</code></th><td data-cell-label=\"仕様\"><span class=\"card-cell-label\">仕様</span>text, audio</td></tr><tr><th data-cell-label=\"パラメータ\" scope=\"row\"><span class=\"card-cell-label\">パラメータ</span><code>required</code></th><td data-cell-label=\"仕様\"><span class=\"card-cell-label\">仕様</span>null</td></tr><tr><th data-cell-label=\"パラメータ\" scope=\"row\"><span class=\"card-cell-label\">パラメータ</span><code>optional_controls</code></th><td data-cell-label=\"仕様\"><span class=\"card-cell-label\">仕様</span>null</td></tr><tr><th data-cell-label=\"パラメータ\" scope=\"row\"><span class=\"card-cell-label\">パラメータ</span><code>content_type</code></th><td data-cell-label=\"仕様\"><span class=\"card-cell-label\">仕様</span>WebSocket</td></tr></tbody></table></div><p>ライフサイクル: <code>exact retained published method</code></p><p class=\"note-s\">メソッドの形式とIDは正確に記載しています。供給元の対応能力とリクエストの受け入れは別です。</p></details></details></section><section class=\"card-section\" data-card-section=\"pricing\"><h3 tabindex=\"-1\">料金</h3><h4>Ailootのメソッド料金</h4><section class=\"meth\" data-route=\"Core\"><header><b><span class=\"alias\">Ailoot</span> リアルタイム音声</b><code>GET /v1/realtime?model=qwen-audio-3.0-realtime-plus</code></header><dl><div><dt>入力</dt><dd>$0.0008 <em>/ 1K</em></dd></div><div><dt>出力</dt><dd>$0.0064 <em>/ 1K</em></dd></div><div><dt>入力</dt><dd>$0.0048 <em>音声1分あたり</em></dd></div><div><dt>出力</dt><dd>$0.018 <em>出力音声1分あたり</em></dd></div></dl></section><p class=\"note-s\">Ailootはリクエスト前に見積額を確保します。結果の取得後、実測使用量に基づいて最終料金を精算します。ストリーミング時の精算には最終の使用量記録を使用します。<a href=\"/docs/ja/billing/reserve/\">金額の確保と精算の仕組み →</a></p></section><section class=\"card-section\" data-card-section=\"examples\"><h3 tabindex=\"-1\">リクエスト例</h3><h4>Ailoot · リアルタイム音声</h4><div class=\"code-group\"><div class=\"cg-bar\"><div class=\"cg-tabs\" role=\"tablist\" aria-label=\"コードの種類\"><button class=\"cg-tab\" id=\"model-code-40-tab-0\" role=\"tab\" type=\"button\" aria-controls=\"model-code-40-panel-0\" aria-selected=\"true\" tabindex=\"0\">Python WebSocket · テキスト</button><button class=\"cg-tab\" id=\"model-code-40-tab-1\" role=\"tab\" type=\"button\" aria-controls=\"model-code-40-panel-1\" aria-selected=\"false\" tabindex=\"-1\">Python WebSocket · 音声</button></div><div class=\"cg-tools\"><button class=\"cg-btn cg-copy\" type=\"button\" aria-label=\"コードをコピー\"><svg class=\"cp\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\"><rect x=\"5.25\" y=\"5.25\" width=\"8.5\" height=\"8.5\" rx=\"1.75\"/><path d=\"M10.75 5.25V3.5a1.25 1.25 0 0 0-1.25-1.25H3.5A1.25 1.25 0 0 0 2.25 3.5v6a1.25 1.25 0 0 0 1.25 1.25h1.75\"/></svg><svg class=\"ok\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\"><path d=\"m3 8.5 3.25 3.25L13 5\"/></svg></button></div></div><div class=\"cg-body\"><div class=\"cg-pane\" id=\"model-code-40-panel-0\" role=\"tabpanel\" aria-labelledby=\"model-code-40-tab-0\"><pre data-lang=\"python\"><code># Install the documented client once: python3 -m pip install websockets\nimport base64, json, os, time, wave\nfrom pathlib import Path\nfrom websockets.sync.client import connect\n\nkey = os.environ.get(&quot;AILOOT_API_KEY&quot;, &quot;&quot;)\nif not key.strip():\n    raise SystemExit(&quot;Set your AILOOT_API_KEY before connecting&quot;)\nfile = Path(os.environ.get(&quot;AILOOT_TEXT_FILE&quot;, &quot;&quot;))\nif not file.is_file(): raise SystemExit(&quot;Set AILOOT_TEXT_FILE to your actual UTF-8 material&quot;)\nmaterial = file.read_text(encoding=&quot;utf-8&quot;)\nif not material.strip(): raise SystemExit(&quot;Text material must not be empty&quot;)\nout = Path(&quot;realtime-results&quot;)\nout.mkdir(exist_ok=True)\naudio, texts, complete = {}, {}, []\ncurrent_response = None\npending = False\ndeadline = time.monotonic() + 570  # Local client bound; lower server/session limits still apply.\n\ndef receive(ws, log):\n    global current_response, pending\n    left = deadline - time.monotonic()\n    if left &lt;= 0:\n        raise TimeoutError(&quot;Client session limit; preserve IDs and partial results, do not replay&quot;)\n    event = json.loads(ws.recv(timeout=min(60, left)))\n    log.write(json.dumps(event, ensure_ascii=False) + &quot;\\n&quot;)\n    log.flush()\n    kind = event.get(&quot;type&quot;)\n    if kind == &quot;error&quot;:\n        raise RuntimeError(json.dumps(event, ensure_ascii=False))\n    if kind == &quot;response.created&quot;:\n        current_response = event[&quot;response&quot;][&quot;id&quot;]\n    if kind in {&quot;response.audio.delta&quot;, &quot;response.output_audio.delta&quot;, &quot;response.text.delta&quot;, &quot;response.output_text.delta&quot;, &quot;response.audio_transcript.delta&quot;, &quot;response.output_audio_transcript.delta&quot;, &quot;response.text.done&quot;, &quot;response.audio_transcript.done&quot;}:\n        identity = (event[&quot;response_id&quot;], event[&quot;item_id&quot;], event[&quot;output_index&quot;], event[&quot;content_index&quot;])\n        if kind in {&quot;response.audio.delta&quot;, &quot;response.output_audio.delta&quot;}:\n            raw = base64.b64decode(event[&quot;delta&quot;], validate=True)\n            if len(raw) % 2: raise ValueError(&quot;Output PCM16 chunk must have an even byte length&quot;)\n            audio.setdefault(identity, bytearray()).extend(raw)\n        elif kind.endswith(&quot;.done&quot;):\n            texts[identity] = event.get(&quot;text&quot;, event.get(&quot;transcript&quot;, &quot;&quot;))\n        else:\n            texts[identity] = texts.get(identity, &quot;&quot;) + event[&quot;delta&quot;]\n            print(event[&quot;delta&quot;], end=&quot;&quot;, flush=True)\n    if kind == &quot;response.done&quot;:\n        response = event[&quot;response&quot;]\n        complete.append(response)\n        if current_response is None: current_response = response[&quot;id&quot;]\n        if response[&quot;id&quot;] == current_response: pending = False\n    return event\n\ndef wait_for(ws, log, kind):\n    while True:\n        event = receive(ws, log)\n        if event.get(&quot;type&quot;) == kind: return event\n\ndef send(ws, event):\n    ws.send(json.dumps(event, ensure_ascii=False))\n\ntry:\n    # One exact model query; no reconnect/retry loop and no provider credentials.\n    with connect(&quot;wss://api.ailoot.ai/v1/realtime?model=qwen-audio-3.0-realtime-plus&quot;, additional_headers={&quot;Authorization&quot;: &quot;Bearer &quot; + key}) as ws:\n        with (out / &quot;events.jsonl&quot;).open(&quot;w&quot;, encoding=&quot;utf-8&quot;) as log:\n            wait_for(ws, log, &quot;session.created&quot;)\n            send(ws, {&quot;type&quot;:&quot;session.update&quot;, &quot;session&quot;:{&quot;modalities&quot;:[&quot;audio&quot;,&quot;text&quot;], &quot;input_audio_format&quot;:&quot;pcm&quot;, &quot;output_audio_format&quot;:&quot;pcm&quot;, &quot;turn_detection&quot;:None}})\n            wait_for(ws, log, &quot;session.updated&quot;)\n            send(ws, {&quot;type&quot;:&quot;conversation.item.create&quot;, &quot;item&quot;:{&quot;type&quot;:&quot;message&quot;, &quot;role&quot;:&quot;user&quot;, &quot;content&quot;:[{&quot;type&quot;:&quot;input_text&quot;, &quot;text&quot;:material}]}})\n            send(ws, {&quot;type&quot;:&quot;response.create&quot;})\n            pending = True\n            try:\n                while pending: receive(ws, log)\n            except KeyboardInterrupt:\n                # Cancel the actual current inference, then preserve its returned status.\n                send(ws, {&quot;type&quot;:&quot;response.cancel&quot;})\n                while pending: receive(ws, log)\n    if not complete or complete[-1].get(&quot;status&quot;) != &quot;completed&quot;:\n        raise RuntimeError(&quot;Response did not complete normally; inspect saved events and status&quot;)\nfinally:\n    manifest = {&quot;responses&quot;:complete, &quot;parts&quot;:[]}\n    for number, identity in enumerate(dict.fromkeys(list(audio) + list(texts))):\n        record = {&quot;response_id&quot;:identity[0], &quot;item_id&quot;:identity[1], &quot;output_index&quot;:identity[2], &quot;content_index&quot;:identity[3]}\n        if identity in audio:\n            raw = bytes(audio[identity])\n            pcm_file = out / (&quot;audio-&quot; + str(number) + &quot;.pcm&quot;)\n            wav_file = out / (&quot;audio-&quot; + str(number) + &quot;.wav&quot;)\n            pcm_file.write_bytes(raw)\n            with wave.open(str(wav_file), &quot;wb&quot;) as wav:\n                wav.setnchannels(1); wav.setsampwidth(2); wav.setframerate(24000); wav.writeframes(raw)\n            record.update({&quot;pcm&quot;:str(pcm_file), &quot;wav&quot;:str(wav_file), &quot;sample_rate_hz&quot;:24000})\n        if identity in texts:\n            text_file = out / (&quot;text-&quot; + str(number) + &quot;.txt&quot;)\n            text_file.write_text(texts[identity], encoding=&quot;utf-8&quot;)\n            record[&quot;text&quot;] = str(text_file)\n        manifest[&quot;parts&quot;].append(record)\n    (out / &quot;results.json&quot;).write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding=&quot;utf-8&quot;)\n    print(&quot;\\nSaved every received event and result in&quot;, out)\n</code></pre></div><div class=\"cg-pane\" id=\"model-code-40-panel-1\" role=\"tabpanel\" aria-labelledby=\"model-code-40-tab-1\" hidden><pre data-lang=\"python\"><code># Install the documented client once: python3 -m pip install websockets\nimport base64, json, os, time, wave\nfrom pathlib import Path\nfrom websockets.sync.client import connect\n\nkey = os.environ.get(&quot;AILOOT_API_KEY&quot;, &quot;&quot;)\nif not key.strip():\n    raise SystemExit(&quot;Set your AILOOT_API_KEY before connecting&quot;)\nfile = Path(os.environ.get(&quot;AILOOT_AUDIO_FILE&quot;, &quot;&quot;))\nif not file.is_file(): raise SystemExit(&quot;Set AILOOT_AUDIO_FILE to your raw PCM16 mono 16-kHz recording&quot;)\nmaterial = file.read_bytes()\nif not material or len(material) % 2 or material.startswith(b&quot;RIFF&quot;):\n    raise SystemExit(&quot;Use nonempty signed little-endian PCM16 mono 16-kHz bytes, not a WAV header&quot;)\nout = Path(&quot;realtime-results&quot;)\nout.mkdir(exist_ok=True)\naudio, texts, complete = {}, {}, []\ncurrent_response = None\npending = False\ndeadline = time.monotonic() + 570  # Local client bound; lower server/session limits still apply.\n\ndef receive(ws, log):\n    global current_response, pending\n    left = deadline - time.monotonic()\n    if left &lt;= 0:\n        raise TimeoutError(&quot;Client session limit; preserve IDs and partial results, do not replay&quot;)\n    event = json.loads(ws.recv(timeout=min(60, left)))\n    log.write(json.dumps(event, ensure_ascii=False) + &quot;\\n&quot;)\n    log.flush()\n    kind = event.get(&quot;type&quot;)\n    if kind == &quot;error&quot;:\n        raise RuntimeError(json.dumps(event, ensure_ascii=False))\n    if kind == &quot;response.created&quot;:\n        current_response = event[&quot;response&quot;][&quot;id&quot;]\n    if kind in {&quot;response.audio.delta&quot;, &quot;response.output_audio.delta&quot;, &quot;response.text.delta&quot;, &quot;response.output_text.delta&quot;, &quot;response.audio_transcript.delta&quot;, &quot;response.output_audio_transcript.delta&quot;, &quot;response.text.done&quot;, &quot;response.audio_transcript.done&quot;}:\n        identity = (event[&quot;response_id&quot;], event[&quot;item_id&quot;], event[&quot;output_index&quot;], event[&quot;content_index&quot;])\n        if kind in {&quot;response.audio.delta&quot;, &quot;response.output_audio.delta&quot;}:\n            raw = base64.b64decode(event[&quot;delta&quot;], validate=True)\n            if len(raw) % 2: raise ValueError(&quot;Output PCM16 chunk must have an even byte length&quot;)\n            audio.setdefault(identity, bytearray()).extend(raw)\n        elif kind.endswith(&quot;.done&quot;):\n            texts[identity] = event.get(&quot;text&quot;, event.get(&quot;transcript&quot;, &quot;&quot;))\n        else:\n            texts[identity] = texts.get(identity, &quot;&quot;) + event[&quot;delta&quot;]\n            print(event[&quot;delta&quot;], end=&quot;&quot;, flush=True)\n    if kind == &quot;response.done&quot;:\n        response = event[&quot;response&quot;]\n        complete.append(response)\n        if current_response is None: current_response = response[&quot;id&quot;]\n        if response[&quot;id&quot;] == current_response: pending = False\n    return event\n\ndef wait_for(ws, log, kind):\n    while True:\n        event = receive(ws, log)\n        if event.get(&quot;type&quot;) == kind: return event\n\ndef send(ws, event):\n    ws.send(json.dumps(event, ensure_ascii=False))\n\ntry:\n    # One exact model query; no reconnect/retry loop and no provider credentials.\n    with connect(&quot;wss://api.ailoot.ai/v1/realtime?model=qwen-audio-3.0-realtime-plus&quot;, additional_headers={&quot;Authorization&quot;: &quot;Bearer &quot; + key}) as ws:\n        with (out / &quot;events.jsonl&quot;).open(&quot;w&quot;, encoding=&quot;utf-8&quot;) as log:\n            wait_for(ws, log, &quot;session.created&quot;)\n            send(ws, {&quot;type&quot;:&quot;session.update&quot;, &quot;session&quot;:{&quot;modalities&quot;:[&quot;audio&quot;,&quot;text&quot;], &quot;input_audio_format&quot;:&quot;pcm&quot;, &quot;output_audio_format&quot;:&quot;pcm&quot;, &quot;turn_detection&quot;:None}})\n            wait_for(ws, log, &quot;session.updated&quot;)\n            for offset in range(0, len(material), 640):\n                send(ws, {&quot;type&quot;:&quot;input_audio_buffer.append&quot;, &quot;audio&quot;:base64.b64encode(material[offset:offset+640]).decode(&quot;ascii&quot;)})\n                time.sleep(0.02)\n            send(ws, {&quot;type&quot;:&quot;input_audio_buffer.commit&quot;})\n            wait_for(ws, log, &quot;input_audio_buffer.committed&quot;)\n            send(ws, {&quot;type&quot;:&quot;response.create&quot;})\n            pending = True\n            try:\n                while pending: receive(ws, log)\n            except KeyboardInterrupt:\n                # Cancel the actual current inference, then preserve its returned status.\n                send(ws, {&quot;type&quot;:&quot;response.cancel&quot;})\n                while pending: receive(ws, log)\n    if not complete or complete[-1].get(&quot;status&quot;) != &quot;completed&quot;:\n        raise RuntimeError(&quot;Response did not complete normally; inspect saved events and status&quot;)\nfinally:\n    manifest = {&quot;responses&quot;:complete, &quot;parts&quot;:[]}\n    for number, identity in enumerate(dict.fromkeys(list(audio) + list(texts))):\n        record = {&quot;response_id&quot;:identity[0], &quot;item_id&quot;:identity[1], &quot;output_index&quot;:identity[2], &quot;content_index&quot;:identity[3]}\n        if identity in audio:\n            raw = bytes(audio[identity])\n            pcm_file = out / (&quot;audio-&quot; + str(number) + &quot;.pcm&quot;)\n            wav_file = out / (&quot;audio-&quot; + str(number) + &quot;.wav&quot;)\n            pcm_file.write_bytes(raw)\n            with wave.open(str(wav_file), &quot;wb&quot;) as wav:\n                wav.setnchannels(1); wav.setsampwidth(2); wav.setframerate(24000); wav.writeframes(raw)\n            record.update({&quot;pcm&quot;:str(pcm_file), &quot;wav&quot;:str(wav_file), &quot;sample_rate_hz&quot;:24000})\n        if identity in texts:\n            text_file = out / (&quot;text-&quot; + str(number) + &quot;.txt&quot;)\n            text_file.write_text(texts[identity], encoding=&quot;utf-8&quot;)\n            record[&quot;text&quot;] = str(text_file)\n        manifest[&quot;parts&quot;].append(record)\n    (out / &quot;results.json&quot;).write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding=&quot;utf-8&quot;)\n    print(&quot;\\nSaved every received event and result in&quot;, out)\n</code></pre></div></div></div></section><section class=\"card-section\" data-card-section=\"results\"><h3 tabindex=\"-1\">結果を受け取って保存</h3><h4>Ailoot · リアルタイム音声</h4><p class=\"note-s\">セッションイベント</p><div class=\"card-result-process\" data-all-results><h5>完了した結果をすべて保存</h5><p class=\"note-s\">返された完全なレスポンス、ファイル、コンテンツ部分をすべて保存してください。</p><p class=\"note-s\">実際のレスポンスIDごとに、返された音声デルタとテキスト／イベントの結果をすべて組み立ててください。</p></div><div class=\"card-result-process\" data-unknown-recovery><h5>元のレスポンスを確認する場合</h5><p class=\"note-s\">実際のセッション／レスポンス／イベントのIDと記録を保持してください。</p></div><details class=\"card-about\" data-method-errors><summary>エラーと次の手順</summary><div class=\"tw\" data-card-table=\"errors\"><table><thead><tr><th>レスポンス</th><th>条件</th><th>次の手順</th></tr></thead><tbody><tr><th data-cell-label=\"レスポンス\" scope=\"row\"><span class=\"card-cell-label\">レスポンス</span>426 · <code>invalid_request_error</code></th><td data-cell-label=\"条件\"><span class=\"card-cell-label\">条件</span>WebSocketへのアップグレードなし</td><td data-cell-label=\"次の手順\"><span class=\"card-cell-label\">次の手順</span>Upgrade: websocketを指定するWebSocketクライアントを使用してください。</td></tr></tbody></table></div></details></section><section class=\"card-section\" data-card-section=\"aliases\"><h3 tabindex=\"-1\">エイリアス</h3><h4>モデルのエイリアス</h4><p class=\"note-s\"><span data-model-alias-route=\"Core\"><b>Ailoot</b> <a href=\"#m=qwen-audio-3.0-realtime-plus&amp;route=Core&amp;caller=qwen-audio-3.0-realtime-plus&amp;fmt=realtime\"><code>qwen-audio-3.0-realtime-plus</code></a></span></p><h4>メソッドパスのエイリアス</h4><p class=\"note-s\">上記に表示されたメソッドパスを使用してください。</p><h4>関連する呼び出し用ID</h4><p class=\"note-s\"><a href=\"#m=qwen-audio-3.0-realtime-plus&amp;route=Core&amp;caller=qwen-audio-3.0-realtime-plus&amp;fmt=realtime\"><code>qwen-audio-3.0-realtime-plus</code></a></p></section></div>",
      "method_identity": {
        "effective_request_model_id": "qwen-audio-3.0-realtime-plus",
        "fmt": "realtime",
        "http": "GET",
        "path": "/v1/realtime?model=qwen-audio-3.0-realtime-plus",
        "request_model_id": "qwen-audio-3.0-realtime-plus",
        "route_label": "Core"
      },
      "method_key": "Core|realtime|/v1/realtime?model=qwen-audio-3.0-realtime-plus|qwen-audio-3.0-realtime-plus",
      "ordinal": 0,
      "rawMethod": {
        "cache_read": null,
        "cache_write": null,
        "cache_write_1h": null,
        "cache_write_5m": null,
        "conditional_meter": null,
        "contract": {
          "data": {
            "all_results": "実際のレスポンスIDごとに、返された音声デルタとテキスト／イベントの結果をすべて組み立ててください。",
            "endpoint": {
              "http": "GET",
              "path": "/v1/realtime",
              "query": {
                "model": "qwen-audio-3.0-realtime-plus"
              },
              "transport": "WebSocket",
              "url": "wss://api.ailoot.ai/v1/realtime?model=qwen-audio-3.0-realtime-plus"
            },
            "errors": [
              {
                "condition": "WebSocketへのアップグレードなし",
                "http_status": 426,
                "recovery": "Upgrade: websocketを指定するWebSocketクライアントを使用してください。",
                "type": "invalid_request_error"
              }
            ],
            "hints": [
              "Append the model query once; do not add another ?model to a URL that already contains it.",
              "Use the actual WebSocket upgrade and API-key authentication.",
              "Tools, web search and voiceprint enhancement are not supported on this exact route."
            ],
            "ignored_fields": [],
            "lifecycle": {
              "close": "Close the actual establishedWebSocket session; no fakeHTTP cancelpath.",
              "mode": "WebSocket session",
              "unknown": "実際のセッション／レスポンス／イベントのIDと記録を保持してください。"
            },
            "material_combinations": [
              {
                "events": [
                  "session.update",
                  "input_audio_buffer.append",
                  "input_audio_buffer.commit",
                  "input_audio_buffer.clear",
                  "response.create",
                  "response.cancel",
                  "conversation.item.create",
                  "conversation.item.retrieve",
                  "conversation.item.delete"
                ],
                "mode": "realtime_text_audio"
              }
            ],
            "operation_modes": [
              "realtime_text_audio"
            ],
            "outputs": {
              "all_outputs": "Assemble every returned audio delta and text/event result for each actual response ID.",
              "audio_format": "PCM16 mono 24 kHz",
              "family": [
                "text",
                "audio"
              ],
              "format": "セッションイベント"
            },
            "parameters": [
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": [
                  "qwen-audio-3.0-realtime-plus"
                ],
                "enum_known": true,
                "enum_status": "specified",
                "name": "query.model",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": [
                  "pcm16",
                  "pcm"
                ],
                "enum_known": true,
                "enum_status": "specified",
                "name": "session.input_audio_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": [
                  "pcm16",
                  "pcm"
                ],
                "enum_known": true,
                "enum_status": "specified",
                "name": "session.output_audio_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": null,
                "enum_known": false,
                "enum_status": "not_specified",
                "limit_scope": "選択したセッションポリシー",
                "name": "session.instructions",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": null,
                "enum_known": false,
                "enum_status": "not_specified",
                "limit_scope": "選択したセッションポリシー",
                "minimum": 1,
                "name": "session.max_history_turns",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "source_interface",
                "content": "PCM16モノラル。入力16 kHz、出力24 kHz。空でなく、バイト長が偶数である必要があります",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": null,
                "enum_known": false,
                "enum_status": "not_specified",
                "name": "input_audio_buffer.append.audio",
                "required": true,
                "type": "base64_string"
              }
            ],
            "unsupported": []
          },
          "hints": [
            "メソッドの形式とIDは正確に記載しています。供給元の対応能力とリクエストの受け入れは別です。"
          ],
          "input": {
            "content_type": "WebSocket",
            "material_types": [
              "text",
              "audio"
            ],
            "optional_controls": null,
            "required": null
          },
          "lifecycle": {
            "mode": "exact retained published method"
          },
          "method": {
            "http": "GET",
            "path": "/v1/realtime?model=qwen-audio-3.0-realtime-plus"
          },
          "operation_modes": [
            "realtime"
          ],
          "output": {
            "family": [
              "text",
              "audio"
            ],
            "format": "session events",
            "multioutputs": "retain every actual response output"
          }
        },
        "ctx": null,
        "examples": [
          {
            "code": "# Install the documented client once: python3 -m pip install websockets\nimport base64, json, os, time, wave\nfrom pathlib import Path\nfrom websockets.sync.client import connect\n\nkey = os.environ.get(\"AILOOT_API_KEY\", \"\")\nif not key.strip():\n    raise SystemExit(\"Set your AILOOT_API_KEY before connecting\")\nfile = Path(os.environ.get(\"AILOOT_TEXT_FILE\", \"\"))\nif not file.is_file(): raise SystemExit(\"Set AILOOT_TEXT_FILE to your actual UTF-8 material\")\nmaterial = file.read_text(encoding=\"utf-8\")\nif not material.strip(): raise SystemExit(\"Text material must not be empty\")\nout = Path(\"realtime-results\")\nout.mkdir(exist_ok=True)\naudio, texts, complete = {}, {}, []\ncurrent_response = None\npending = False\ndeadline = time.monotonic() + 570  # Local client bound; lower server/session limits still apply.\n\ndef receive(ws, log):\n    global current_response, pending\n    left = deadline - time.monotonic()\n    if left <= 0:\n        raise TimeoutError(\"Client session limit; preserve IDs and partial results, do not replay\")\n    event = json.loads(ws.recv(timeout=min(60, left)))\n    log.write(json.dumps(event, ensure_ascii=False) + \"\\n\")\n    log.flush()\n    kind = event.get(\"type\")\n    if kind == \"error\":\n        raise RuntimeError(json.dumps(event, ensure_ascii=False))\n    if kind == \"response.created\":\n        current_response = event[\"response\"][\"id\"]\n    if kind in {\"response.audio.delta\", \"response.output_audio.delta\", \"response.text.delta\", \"response.output_text.delta\", \"response.audio_transcript.delta\", \"response.output_audio_transcript.delta\", \"response.text.done\", \"response.audio_transcript.done\"}:\n        identity = (event[\"response_id\"], event[\"item_id\"], event[\"output_index\"], event[\"content_index\"])\n        if kind in {\"response.audio.delta\", \"response.output_audio.delta\"}:\n            raw = base64.b64decode(event[\"delta\"], validate=True)\n            if len(raw) % 2: raise ValueError(\"Output PCM16 chunk must have an even byte length\")\n            audio.setdefault(identity, bytearray()).extend(raw)\n        elif kind.endswith(\".done\"):\n            texts[identity] = event.get(\"text\", event.get(\"transcript\", \"\"))\n        else:\n            texts[identity] = texts.get(identity, \"\") + event[\"delta\"]\n            print(event[\"delta\"], end=\"\", flush=True)\n    if kind == \"response.done\":\n        response = event[\"response\"]\n        complete.append(response)\n        if current_response is None: current_response = response[\"id\"]\n        if response[\"id\"] == current_response: pending = False\n    return event\n\ndef wait_for(ws, log, kind):\n    while True:\n        event = receive(ws, log)\n        if event.get(\"type\") == kind: return event\n\ndef send(ws, event):\n    ws.send(json.dumps(event, ensure_ascii=False))\n\ntry:\n    # One exact model query; no reconnect/retry loop and no provider credentials.\n    with connect(\"wss://api.ailoot.ai/v1/realtime?model=qwen-audio-3.0-realtime-plus\", additional_headers={\"Authorization\": \"Bearer \" + key}) as ws:\n        with (out / \"events.jsonl\").open(\"w\", encoding=\"utf-8\") as log:\n            wait_for(ws, log, \"session.created\")\n            send(ws, {\"type\":\"session.update\", \"session\":{\"modalities\":[\"audio\",\"text\"], \"input_audio_format\":\"pcm\", \"output_audio_format\":\"pcm\", \"turn_detection\":None}})\n            wait_for(ws, log, \"session.updated\")\n            send(ws, {\"type\":\"conversation.item.create\", \"item\":{\"type\":\"message\", \"role\":\"user\", \"content\":[{\"type\":\"input_text\", \"text\":material}]}})\n            send(ws, {\"type\":\"response.create\"})\n            pending = True\n            try:\n                while pending: receive(ws, log)\n            except KeyboardInterrupt:\n                # Cancel the actual current inference, then preserve its returned status.\n                send(ws, {\"type\":\"response.cancel\"})\n                while pending: receive(ws, log)\n    if not complete or complete[-1].get(\"status\") != \"completed\":\n        raise RuntimeError(\"Response did not complete normally; inspect saved events and status\")\nfinally:\n    manifest = {\"responses\":complete, \"parts\":[]}\n    for number, identity in enumerate(dict.fromkeys(list(audio) + list(texts))):\n        record = {\"response_id\":identity[0], \"item_id\":identity[1], \"output_index\":identity[2], \"content_index\":identity[3]}\n        if identity in audio:\n            raw = bytes(audio[identity])\n            pcm_file = out / (\"audio-\" + str(number) + \".pcm\")\n            wav_file = out / (\"audio-\" + str(number) + \".wav\")\n            pcm_file.write_bytes(raw)\n            with wave.open(str(wav_file), \"wb\") as wav:\n                wav.setnchannels(1); wav.setsampwidth(2); wav.setframerate(24000); wav.writeframes(raw)\n            record.update({\"pcm\":str(pcm_file), \"wav\":str(wav_file), \"sample_rate_hz\":24000})\n        if identity in texts:\n            text_file = out / (\"text-\" + str(number) + \".txt\")\n            text_file.write_text(texts[identity], encoding=\"utf-8\")\n            record[\"text\"] = str(text_file)\n        manifest[\"parts\"].append(record)\n    (out / \"results.json\").write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding=\"utf-8\")\n    print(\"\\nSaved every received event and result in\", out)\n",
            "label": "Python WebSocket · text material and all text/audio results",
            "language": "python"
          },
          {
            "code": "# Install the documented client once: python3 -m pip install websockets\nimport base64, json, os, time, wave\nfrom pathlib import Path\nfrom websockets.sync.client import connect\n\nkey = os.environ.get(\"AILOOT_API_KEY\", \"\")\nif not key.strip():\n    raise SystemExit(\"Set your AILOOT_API_KEY before connecting\")\nfile = Path(os.environ.get(\"AILOOT_AUDIO_FILE\", \"\"))\nif not file.is_file(): raise SystemExit(\"Set AILOOT_AUDIO_FILE to your raw PCM16 mono 16-kHz recording\")\nmaterial = file.read_bytes()\nif not material or len(material) % 2 or material.startswith(b\"RIFF\"):\n    raise SystemExit(\"Use nonempty signed little-endian PCM16 mono 16-kHz bytes, not a WAV header\")\nout = Path(\"realtime-results\")\nout.mkdir(exist_ok=True)\naudio, texts, complete = {}, {}, []\ncurrent_response = None\npending = False\ndeadline = time.monotonic() + 570  # Local client bound; lower server/session limits still apply.\n\ndef receive(ws, log):\n    global current_response, pending\n    left = deadline - time.monotonic()\n    if left <= 0:\n        raise TimeoutError(\"Client session limit; preserve IDs and partial results, do not replay\")\n    event = json.loads(ws.recv(timeout=min(60, left)))\n    log.write(json.dumps(event, ensure_ascii=False) + \"\\n\")\n    log.flush()\n    kind = event.get(\"type\")\n    if kind == \"error\":\n        raise RuntimeError(json.dumps(event, ensure_ascii=False))\n    if kind == \"response.created\":\n        current_response = event[\"response\"][\"id\"]\n    if kind in {\"response.audio.delta\", \"response.output_audio.delta\", \"response.text.delta\", \"response.output_text.delta\", \"response.audio_transcript.delta\", \"response.output_audio_transcript.delta\", \"response.text.done\", \"response.audio_transcript.done\"}:\n        identity = (event[\"response_id\"], event[\"item_id\"], event[\"output_index\"], event[\"content_index\"])\n        if kind in {\"response.audio.delta\", \"response.output_audio.delta\"}:\n            raw = base64.b64decode(event[\"delta\"], validate=True)\n            if len(raw) % 2: raise ValueError(\"Output PCM16 chunk must have an even byte length\")\n            audio.setdefault(identity, bytearray()).extend(raw)\n        elif kind.endswith(\".done\"):\n            texts[identity] = event.get(\"text\", event.get(\"transcript\", \"\"))\n        else:\n            texts[identity] = texts.get(identity, \"\") + event[\"delta\"]\n            print(event[\"delta\"], end=\"\", flush=True)\n    if kind == \"response.done\":\n        response = event[\"response\"]\n        complete.append(response)\n        if current_response is None: current_response = response[\"id\"]\n        if response[\"id\"] == current_response: pending = False\n    return event\n\ndef wait_for(ws, log, kind):\n    while True:\n        event = receive(ws, log)\n        if event.get(\"type\") == kind: return event\n\ndef send(ws, event):\n    ws.send(json.dumps(event, ensure_ascii=False))\n\ntry:\n    # One exact model query; no reconnect/retry loop and no provider credentials.\n    with connect(\"wss://api.ailoot.ai/v1/realtime?model=qwen-audio-3.0-realtime-plus\", additional_headers={\"Authorization\": \"Bearer \" + key}) as ws:\n        with (out / \"events.jsonl\").open(\"w\", encoding=\"utf-8\") as log:\n            wait_for(ws, log, \"session.created\")\n            send(ws, {\"type\":\"session.update\", \"session\":{\"modalities\":[\"audio\",\"text\"], \"input_audio_format\":\"pcm\", \"output_audio_format\":\"pcm\", \"turn_detection\":None}})\n            wait_for(ws, log, \"session.updated\")\n            for offset in range(0, len(material), 640):\n                send(ws, {\"type\":\"input_audio_buffer.append\", \"audio\":base64.b64encode(material[offset:offset+640]).decode(\"ascii\")})\n                time.sleep(0.02)\n            send(ws, {\"type\":\"input_audio_buffer.commit\"})\n            wait_for(ws, log, \"input_audio_buffer.committed\")\n            send(ws, {\"type\":\"response.create\"})\n            pending = True\n            try:\n                while pending: receive(ws, log)\n            except KeyboardInterrupt:\n                # Cancel the actual current inference, then preserve its returned status.\n                send(ws, {\"type\":\"response.cancel\"})\n                while pending: receive(ws, log)\n    if not complete or complete[-1].get(\"status\") != \"completed\":\n        raise RuntimeError(\"Response did not complete normally; inspect saved events and status\")\nfinally:\n    manifest = {\"responses\":complete, \"parts\":[]}\n    for number, identity in enumerate(dict.fromkeys(list(audio) + list(texts))):\n        record = {\"response_id\":identity[0], \"item_id\":identity[1], \"output_index\":identity[2], \"content_index\":identity[3]}\n        if identity in audio:\n            raw = bytes(audio[identity])\n            pcm_file = out / (\"audio-\" + str(number) + \".pcm\")\n            wav_file = out / (\"audio-\" + str(number) + \".wav\")\n            pcm_file.write_bytes(raw)\n            with wave.open(str(wav_file), \"wb\") as wav:\n                wav.setnchannels(1); wav.setsampwidth(2); wav.setframerate(24000); wav.writeframes(raw)\n            record.update({\"pcm\":str(pcm_file), \"wav\":str(wav_file), \"sample_rate_hz\":24000})\n        if identity in texts:\n            text_file = out / (\"text-\" + str(number) + \".txt\")\n            text_file.write_text(texts[identity], encoding=\"utf-8\")\n            record[\"text\"] = str(text_file)\n        manifest[\"parts\"].append(record)\n    (out / \"results.json\").write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding=\"utf-8\")\n    print(\"\\nSaved every received event and result in\", out)\n",
            "label": "Python WebSocket · actual PCM recording and all results",
            "language": "python"
          }
        ],
        "family": "openai",
        "fast_multiplier": null,
        "flex_multiplier": null,
        "fmt": "realtime",
        "http": "GET",
        "img_in": null,
        "img_out": null,
        "in": 0.8,
        "input": [
          "text",
          "audio"
        ],
        "label": "リアルタイム音声",
        "max_out": null,
        "max_tool_calls": null,
        "out": 6.4,
        "output": [
          "text",
          "audio"
        ],
        "path": "/v1/realtime?model=qwen-audio-3.0-realtime-plus",
        "pricing_profiles": [
          {
            "dimensions": {},
            "label": "Core",
            "units": [
              {
                "amount": 0.8,
                "amount_unit": "usd_per_million_tokens",
                "key": "in",
                "label": "Input",
                "side": "in"
              },
              {
                "amount": 6.4,
                "amount_unit": "usd_per_million_tokens",
                "key": "out",
                "label": "Output",
                "side": "out"
              },
              {
                "amount": 0.0048,
                "amount_unit": "usd_per_display_unit",
                "key": "audio_input_second",
                "label": "per minute of audio",
                "side": "in"
              },
              {
                "amount": 0.018,
                "amount_unit": "usd_per_display_unit",
                "key": "audio_output_second",
                "label": "per minute of output audio",
                "side": "out"
              }
            ]
          }
        ],
        "request_model_id": "qwen-audio-3.0-realtime-plus",
        "route_label": "Core",
        "status_reads": [],
        "tiers": [],
        "tool_prices": null,
        "unit": "conditional",
        "units": [
          {
            "key": "audio_input_second",
            "label": "per minute of audio",
            "side": "in",
            "usd": 0.0048
          },
          {
            "key": "audio_output_second",
            "label": "per minute of output audio",
            "side": "out",
            "usd": 0.018
          }
        ]
      }
    }
  ],
  "model_id": "qwen-audio-3.0-realtime-plus",
  "nativeProvenance": {
    "input_facts_canonical_sha256": "f11dc86dc073f5d716c3bacca91199bf7a39caf73c3ec42794dfc8bf29dacf29",
    "input_html_sha256": "8ba40ed7557230b7ca42f6babf7483039840b9d6386204601b41acc0c245089d",
    "private_audit_sha256": "a5620f29fb1a1ebb6d37c66733bc9e3e94767a4dad4a66e305baf1762b2cbbc0",
    "role": "historical-normalized-input-audit-hashes",
    "schema": "ailoot-native-model-provenance-v2"
  },
  "page": {
    "canonical": "https://ailoot.ai/models/ja/qwen-audio-3-0-realtime-plus/",
    "description": "音声とテキストを受け取り、音声またはテキストで応答するリアルタイム音声対話モデルです。自然な会話のテンポとツールとの連携を想定しています。",
    "locale": "ja",
    "md_url": "https://ailoot.ai/models/ja/qwen-audio-3-0-realtime-plus/index.md",
    "title": "qwen-audio-3.0-realtime-plus — Ailoot",
    "url": "https://ailoot.ai/models/ja/qwen-audio-3-0-realtime-plus/"
  },
  "rawModel": {
    "about": "Qwen-Audio-3.0-Realtime-Plusは、リアルタイム音声対話のためのAlibabaのモデルです。音声とテキストを受け取り、音声とテキストで応答し、自然なやり取りによる双方向の会話に対応します。音声は分割して送受信できるため、会話の進行中にやり取りを続けられます。\n\n### 相手が話し終えたタイミング\n\n発話の区切りを判断する方法として、音声の活動、意味上の完結、明示的な制御が用意されています。メーカーでは、最初の音声を送る前にモードを選択し、会話の開始後に変更するには新しい接続が必要です。この制御への対応は、選択したメソッドによって決まります。意味を考慮するモードでは、間や言いよどみも判断材料にするため、短いためらいが必ずしもユーザーの話の終わりを意味しません。ユーザーが新たに話し始めると、生成中の応答を中断し、次の発話を踏まえて会話を続けられます。意味を考慮するモードでは、選択した相手の音声サンプルを認識の手掛かりにし、他の人の声や背景の雑音に気を取られにくくすることもできます。\n\n指示はアシスタントの役割や会話のスタイルを定めます。音声表現にはトーン、速度、感情を反映でき、バージョン3.0には五つのシステム音声と、音声サンプルに基づく声が用意されています。モデルはロシア語を含む11言語と、メーカーが指定する中国語の方言に対応しています。メーカーでは、最初のセッション設定更新時に声を指定し、同じ会話で後から新しい声を送っても無視されます。これらの設定には、選択したアクセス方法での対応が必要です。\n\n### ツールと会話履歴\n\n関数呼び出しに対応しています。モデルが必要な動作を提示し、接続されたアプリケーションが実行して結果を会話に返します。実際のデータに基づいて会話を組み立て、処理の実行後も続けられます。音声アシスタントは、会話の文脈を保ちながらツールの結果を利用できます。メーカーの機能には、選択したメソッドで提供される場合の組み込みウェブ検索も含まれます。ウェブ検索と関数呼び出しは、同じセッションで同時に有効にできません。\n\n既定では会話履歴を20ターン保持し、一ターンから50ターンまで設定できます。蓄積した音声の上限は300秒で、制限を超えると古い履歴が削除されます。これは個々の発話の長さとは異なります。履歴は、会話を続ける際に以前のどの素材を利用できるかを決めます。\n\n### テキストのコンテキストと音声\n\n公称コンテキストは40 960トークンです。入力の最大長は16 384トークン、出力は8192トークンです。推論モードにも同じ入力と出力の上限が示されており、推論の連鎖には別途1024トークンの上限があります。\n\nストリーミング音声には、16ビットのモノラルPCMを使用し、入力は16キロヘルツ、出力は24キロヘルツです。テキストと音声のデータは同じ会話に属します。このモデルについて、視覚的な入力や画像の出力は公表されていません。専門領域は発話、テキスト、音声によるやり取りです。",
    "alias_of": null,
    "aliases": [],
    "author": "Alibaba",
    "ctx": null,
    "formats": [
      "realtime"
    ],
    "id": "qwen-audio-3.0-realtime-plus",
    "input": [
      "text",
      "audio"
    ],
    "kind": "speech",
    "max_out": null,
    "methods": [
      {
        "cache_read": null,
        "cache_write": null,
        "cache_write_1h": null,
        "cache_write_5m": null,
        "conditional_meter": null,
        "contract": {
          "data": {
            "all_results": "実際のレスポンスIDごとに、返された音声デルタとテキスト／イベントの結果をすべて組み立ててください。",
            "endpoint": {
              "http": "GET",
              "path": "/v1/realtime",
              "query": {
                "model": "qwen-audio-3.0-realtime-plus"
              },
              "transport": "WebSocket",
              "url": "wss://api.ailoot.ai/v1/realtime?model=qwen-audio-3.0-realtime-plus"
            },
            "errors": [
              {
                "condition": "WebSocketへのアップグレードなし",
                "http_status": 426,
                "recovery": "Upgrade: websocketを指定するWebSocketクライアントを使用してください。",
                "type": "invalid_request_error"
              }
            ],
            "hints": [
              "Append the model query once; do not add another ?model to a URL that already contains it.",
              "Use the actual WebSocket upgrade and API-key authentication.",
              "Tools, web search and voiceprint enhancement are not supported on this exact route."
            ],
            "ignored_fields": [],
            "lifecycle": {
              "close": "Close the actual establishedWebSocket session; no fakeHTTP cancelpath.",
              "mode": "WebSocket session",
              "unknown": "実際のセッション／レスポンス／イベントのIDと記録を保持してください。"
            },
            "material_combinations": [
              {
                "events": [
                  "session.update",
                  "input_audio_buffer.append",
                  "input_audio_buffer.commit",
                  "input_audio_buffer.clear",
                  "response.create",
                  "response.cancel",
                  "conversation.item.create",
                  "conversation.item.retrieve",
                  "conversation.item.delete"
                ],
                "mode": "realtime_text_audio"
              }
            ],
            "operation_modes": [
              "realtime_text_audio"
            ],
            "outputs": {
              "all_outputs": "Assemble every returned audio delta and text/event result for each actual response ID.",
              "audio_format": "PCM16 mono 24 kHz",
              "family": [
                "text",
                "audio"
              ],
              "format": "セッションイベント"
            },
            "parameters": [
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": [
                  "qwen-audio-3.0-realtime-plus"
                ],
                "enum_known": true,
                "enum_status": "specified",
                "name": "query.model",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": [
                  "pcm16",
                  "pcm"
                ],
                "enum_known": true,
                "enum_status": "specified",
                "name": "session.input_audio_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": [
                  "pcm16",
                  "pcm"
                ],
                "enum_known": true,
                "enum_status": "specified",
                "name": "session.output_audio_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": null,
                "enum_known": false,
                "enum_status": "not_specified",
                "limit_scope": "選択したセッションポリシー",
                "name": "session.instructions",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": null,
                "enum_known": false,
                "enum_status": "not_specified",
                "limit_scope": "選択したセッションポリシー",
                "minimum": 1,
                "name": "session.max_history_turns",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "source_interface",
                "content": "PCM16モノラル。入力16 kHz、出力24 kHz。空でなく、バイト長が偶数である必要があります",
                "default": null,
                "default_known": false,
                "default_status": "not_specified",
                "enum": null,
                "enum_known": false,
                "enum_status": "not_specified",
                "name": "input_audio_buffer.append.audio",
                "required": true,
                "type": "base64_string"
              }
            ],
            "unsupported": []
          },
          "hints": [
            "メソッドの形式とIDは正確に記載しています。供給元の対応能力とリクエストの受け入れは別です。"
          ],
          "input": {
            "content_type": "WebSocket",
            "material_types": [
              "text",
              "audio"
            ],
            "optional_controls": null,
            "required": null
          },
          "lifecycle": {
            "mode": "exact retained published method"
          },
          "method": {
            "http": "GET",
            "path": "/v1/realtime?model=qwen-audio-3.0-realtime-plus"
          },
          "operation_modes": [
            "realtime"
          ],
          "output": {
            "family": [
              "text",
              "audio"
            ],
            "format": "session events",
            "multioutputs": "retain every actual response output"
          }
        },
        "ctx": null,
        "examples": [
          {
            "code": "# Install the documented client once: python3 -m pip install websockets\nimport base64, json, os, time, wave\nfrom pathlib import Path\nfrom websockets.sync.client import connect\n\nkey = os.environ.get(\"AILOOT_API_KEY\", \"\")\nif not key.strip():\n    raise SystemExit(\"Set your AILOOT_API_KEY before connecting\")\nfile = Path(os.environ.get(\"AILOOT_TEXT_FILE\", \"\"))\nif not file.is_file(): raise SystemExit(\"Set AILOOT_TEXT_FILE to your actual UTF-8 material\")\nmaterial = file.read_text(encoding=\"utf-8\")\nif not material.strip(): raise SystemExit(\"Text material must not be empty\")\nout = Path(\"realtime-results\")\nout.mkdir(exist_ok=True)\naudio, texts, complete = {}, {}, []\ncurrent_response = None\npending = False\ndeadline = time.monotonic() + 570  # Local client bound; lower server/session limits still apply.\n\ndef receive(ws, log):\n    global current_response, pending\n    left = deadline - time.monotonic()\n    if left <= 0:\n        raise TimeoutError(\"Client session limit; preserve IDs and partial results, do not replay\")\n    event = json.loads(ws.recv(timeout=min(60, left)))\n    log.write(json.dumps(event, ensure_ascii=False) + \"\\n\")\n    log.flush()\n    kind = event.get(\"type\")\n    if kind == \"error\":\n        raise RuntimeError(json.dumps(event, ensure_ascii=False))\n    if kind == \"response.created\":\n        current_response = event[\"response\"][\"id\"]\n    if kind in {\"response.audio.delta\", \"response.output_audio.delta\", \"response.text.delta\", \"response.output_text.delta\", \"response.audio_transcript.delta\", \"response.output_audio_transcript.delta\", \"response.text.done\", \"response.audio_transcript.done\"}:\n        identity = (event[\"response_id\"], event[\"item_id\"], event[\"output_index\"], event[\"content_index\"])\n        if kind in {\"response.audio.delta\", \"response.output_audio.delta\"}:\n            raw = base64.b64decode(event[\"delta\"], validate=True)\n            if len(raw) % 2: raise ValueError(\"Output PCM16 chunk must have an even byte length\")\n            audio.setdefault(identity, bytearray()).extend(raw)\n        elif kind.endswith(\".done\"):\n            texts[identity] = event.get(\"text\", event.get(\"transcript\", \"\"))\n        else:\n            texts[identity] = texts.get(identity, \"\") + event[\"delta\"]\n            print(event[\"delta\"], end=\"\", flush=True)\n    if kind == \"response.done\":\n        response = event[\"response\"]\n        complete.append(response)\n        if current_response is None: current_response = response[\"id\"]\n        if response[\"id\"] == current_response: pending = False\n    return event\n\ndef wait_for(ws, log, kind):\n    while True:\n        event = receive(ws, log)\n        if event.get(\"type\") == kind: return event\n\ndef send(ws, event):\n    ws.send(json.dumps(event, ensure_ascii=False))\n\ntry:\n    # One exact model query; no reconnect/retry loop and no provider credentials.\n    with connect(\"wss://api.ailoot.ai/v1/realtime?model=qwen-audio-3.0-realtime-plus\", additional_headers={\"Authorization\": \"Bearer \" + key}) as ws:\n        with (out / \"events.jsonl\").open(\"w\", encoding=\"utf-8\") as log:\n            wait_for(ws, log, \"session.created\")\n            send(ws, {\"type\":\"session.update\", \"session\":{\"modalities\":[\"audio\",\"text\"], \"input_audio_format\":\"pcm\", \"output_audio_format\":\"pcm\", \"turn_detection\":None}})\n            wait_for(ws, log, \"session.updated\")\n            send(ws, {\"type\":\"conversation.item.create\", \"item\":{\"type\":\"message\", \"role\":\"user\", \"content\":[{\"type\":\"input_text\", \"text\":material}]}})\n            send(ws, {\"type\":\"response.create\"})\n            pending = True\n            try:\n                while pending: receive(ws, log)\n            except KeyboardInterrupt:\n                # Cancel the actual current inference, then preserve its returned status.\n                send(ws, {\"type\":\"response.cancel\"})\n                while pending: receive(ws, log)\n    if not complete or complete[-1].get(\"status\") != \"completed\":\n        raise RuntimeError(\"Response did not complete normally; inspect saved events and status\")\nfinally:\n    manifest = {\"responses\":complete, \"parts\":[]}\n    for number, identity in enumerate(dict.fromkeys(list(audio) + list(texts))):\n        record = {\"response_id\":identity[0], \"item_id\":identity[1], \"output_index\":identity[2], \"content_index\":identity[3]}\n        if identity in audio:\n            raw = bytes(audio[identity])\n            pcm_file = out / (\"audio-\" + str(number) + \".pcm\")\n            wav_file = out / (\"audio-\" + str(number) + \".wav\")\n            pcm_file.write_bytes(raw)\n            with wave.open(str(wav_file), \"wb\") as wav:\n                wav.setnchannels(1); wav.setsampwidth(2); wav.setframerate(24000); wav.writeframes(raw)\n            record.update({\"pcm\":str(pcm_file), \"wav\":str(wav_file), \"sample_rate_hz\":24000})\n        if identity in texts:\n            text_file = out / (\"text-\" + str(number) + \".txt\")\n            text_file.write_text(texts[identity], encoding=\"utf-8\")\n            record[\"text\"] = str(text_file)\n        manifest[\"parts\"].append(record)\n    (out / \"results.json\").write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding=\"utf-8\")\n    print(\"\\nSaved every received event and result in\", out)\n",
            "label": "Python WebSocket · text material and all text/audio results",
            "language": "python"
          },
          {
            "code": "# Install the documented client once: python3 -m pip install websockets\nimport base64, json, os, time, wave\nfrom pathlib import Path\nfrom websockets.sync.client import connect\n\nkey = os.environ.get(\"AILOOT_API_KEY\", \"\")\nif not key.strip():\n    raise SystemExit(\"Set your AILOOT_API_KEY before connecting\")\nfile = Path(os.environ.get(\"AILOOT_AUDIO_FILE\", \"\"))\nif not file.is_file(): raise SystemExit(\"Set AILOOT_AUDIO_FILE to your raw PCM16 mono 16-kHz recording\")\nmaterial = file.read_bytes()\nif not material or len(material) % 2 or material.startswith(b\"RIFF\"):\n    raise SystemExit(\"Use nonempty signed little-endian PCM16 mono 16-kHz bytes, not a WAV header\")\nout = Path(\"realtime-results\")\nout.mkdir(exist_ok=True)\naudio, texts, complete = {}, {}, []\ncurrent_response = None\npending = False\ndeadline = time.monotonic() + 570  # Local client bound; lower server/session limits still apply.\n\ndef receive(ws, log):\n    global current_response, pending\n    left = deadline - time.monotonic()\n    if left <= 0:\n        raise TimeoutError(\"Client session limit; preserve IDs and partial results, do not replay\")\n    event = json.loads(ws.recv(timeout=min(60, left)))\n    log.write(json.dumps(event, ensure_ascii=False) + \"\\n\")\n    log.flush()\n    kind = event.get(\"type\")\n    if kind == \"error\":\n        raise RuntimeError(json.dumps(event, ensure_ascii=False))\n    if kind == \"response.created\":\n        current_response = event[\"response\"][\"id\"]\n    if kind in {\"response.audio.delta\", \"response.output_audio.delta\", \"response.text.delta\", \"response.output_text.delta\", \"response.audio_transcript.delta\", \"response.output_audio_transcript.delta\", \"response.text.done\", \"response.audio_transcript.done\"}:\n        identity = (event[\"response_id\"], event[\"item_id\"], event[\"output_index\"], event[\"content_index\"])\n        if kind in {\"response.audio.delta\", \"response.output_audio.delta\"}:\n            raw = base64.b64decode(event[\"delta\"], validate=True)\n            if len(raw) % 2: raise ValueError(\"Output PCM16 chunk must have an even byte length\")\n            audio.setdefault(identity, bytearray()).extend(raw)\n        elif kind.endswith(\".done\"):\n            texts[identity] = event.get(\"text\", event.get(\"transcript\", \"\"))\n        else:\n            texts[identity] = texts.get(identity, \"\") + event[\"delta\"]\n            print(event[\"delta\"], end=\"\", flush=True)\n    if kind == \"response.done\":\n        response = event[\"response\"]\n        complete.append(response)\n        if current_response is None: current_response = response[\"id\"]\n        if response[\"id\"] == current_response: pending = False\n    return event\n\ndef wait_for(ws, log, kind):\n    while True:\n        event = receive(ws, log)\n        if event.get(\"type\") == kind: return event\n\ndef send(ws, event):\n    ws.send(json.dumps(event, ensure_ascii=False))\n\ntry:\n    # One exact model query; no reconnect/retry loop and no provider credentials.\n    with connect(\"wss://api.ailoot.ai/v1/realtime?model=qwen-audio-3.0-realtime-plus\", additional_headers={\"Authorization\": \"Bearer \" + key}) as ws:\n        with (out / \"events.jsonl\").open(\"w\", encoding=\"utf-8\") as log:\n            wait_for(ws, log, \"session.created\")\n            send(ws, {\"type\":\"session.update\", \"session\":{\"modalities\":[\"audio\",\"text\"], \"input_audio_format\":\"pcm\", \"output_audio_format\":\"pcm\", \"turn_detection\":None}})\n            wait_for(ws, log, \"session.updated\")\n            for offset in range(0, len(material), 640):\n                send(ws, {\"type\":\"input_audio_buffer.append\", \"audio\":base64.b64encode(material[offset:offset+640]).decode(\"ascii\")})\n                time.sleep(0.02)\n            send(ws, {\"type\":\"input_audio_buffer.commit\"})\n            wait_for(ws, log, \"input_audio_buffer.committed\")\n            send(ws, {\"type\":\"response.create\"})\n            pending = True\n            try:\n                while pending: receive(ws, log)\n            except KeyboardInterrupt:\n                # Cancel the actual current inference, then preserve its returned status.\n                send(ws, {\"type\":\"response.cancel\"})\n                while pending: receive(ws, log)\n    if not complete or complete[-1].get(\"status\") != \"completed\":\n        raise RuntimeError(\"Response did not complete normally; inspect saved events and status\")\nfinally:\n    manifest = {\"responses\":complete, \"parts\":[]}\n    for number, identity in enumerate(dict.fromkeys(list(audio) + list(texts))):\n        record = {\"response_id\":identity[0], \"item_id\":identity[1], \"output_index\":identity[2], \"content_index\":identity[3]}\n        if identity in audio:\n            raw = bytes(audio[identity])\n            pcm_file = out / (\"audio-\" + str(number) + \".pcm\")\n            wav_file = out / (\"audio-\" + str(number) + \".wav\")\n            pcm_file.write_bytes(raw)\n            with wave.open(str(wav_file), \"wb\") as wav:\n                wav.setnchannels(1); wav.setsampwidth(2); wav.setframerate(24000); wav.writeframes(raw)\n            record.update({\"pcm\":str(pcm_file), \"wav\":str(wav_file), \"sample_rate_hz\":24000})\n        if identity in texts:\n            text_file = out / (\"text-\" + str(number) + \".txt\")\n            text_file.write_text(texts[identity], encoding=\"utf-8\")\n            record[\"text\"] = str(text_file)\n        manifest[\"parts\"].append(record)\n    (out / \"results.json\").write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding=\"utf-8\")\n    print(\"\\nSaved every received event and result in\", out)\n",
            "label": "Python WebSocket · actual PCM recording and all results",
            "language": "python"
          }
        ],
        "family": "openai",
        "fast_multiplier": null,
        "flex_multiplier": null,
        "fmt": "realtime",
        "http": "GET",
        "img_in": null,
        "img_out": null,
        "in": 0.8,
        "input": [
          "text",
          "audio"
        ],
        "label": "リアルタイム音声",
        "max_out": null,
        "max_tool_calls": null,
        "out": 6.4,
        "output": [
          "text",
          "audio"
        ],
        "path": "/v1/realtime?model=qwen-audio-3.0-realtime-plus",
        "pricing_profiles": [
          {
            "dimensions": {},
            "label": "Core",
            "units": [
              {
                "amount": 0.8,
                "amount_unit": "usd_per_million_tokens",
                "key": "in",
                "label": "Input",
                "side": "in"
              },
              {
                "amount": 6.4,
                "amount_unit": "usd_per_million_tokens",
                "key": "out",
                "label": "Output",
                "side": "out"
              },
              {
                "amount": 0.0048,
                "amount_unit": "usd_per_display_unit",
                "key": "audio_input_second",
                "label": "per minute of audio",
                "side": "in"
              },
              {
                "amount": 0.018,
                "amount_unit": "usd_per_display_unit",
                "key": "audio_output_second",
                "label": "per minute of output audio",
                "side": "out"
              }
            ]
          }
        ],
        "request_model_id": "qwen-audio-3.0-realtime-plus",
        "route_label": "Core",
        "status_reads": [],
        "tiers": [],
        "tool_prices": null,
        "unit": "conditional",
        "units": [
          {
            "key": "audio_input_second",
            "label": "per minute of audio",
            "side": "in",
            "usd": 0.0048
          },
          {
            "key": "audio_output_second",
            "label": "per minute of output audio",
            "side": "out",
            "usd": 0.018
          }
        ]
      }
    ],
    "model_aliases": [
      {
        "canonical_model_id": "qwen-audio-3.0-realtime-plus",
        "request_model_id": "qwen-audio-3.0-realtime-plus",
        "route_label": "Core"
      }
    ],
    "name": "qwen-audio-3.0-realtime-plus",
    "price": {
      "in": 0.8,
      "in_label": null,
      "out": 6.4,
      "out_label": null,
      "sort_in": 0.8,
      "sort_out": 6.4,
      "varies": false
    },
    "short": "音声とテキストを受け取り、音声またはテキストで応答するリアルタイム音声対話モデルです。自然な会話のテンポとツールとの連携を想定しています。"
  },
  "renderer_schema": {
    "method_order": "Original DTO methods order; every exact route/format/path/caller survives.",
    "prices": "Original public DTO fields and original native display HTML; no flattened or normalized offers."
  },
  "representation": "exact-public-dto-and-native-renderer-html",
  "representationNotes": {
    "current_reference": {
      "about_json_pointer": "/aboutHtml",
      "methods": [
        {
          "contract_json_pointer": "/methods/0/rawMethod/contract",
          "html_json_pointer": "/methods/0/html",
          "method_ordinal": 0
        }
      ],
      "role": "current-semantic-reference"
    },
    "raw_input": {
      "examples_role": "historical-input-not-current-ready-examples",
      "json_pointers": [
        "/rawModel",
        "/methods/0/rawMethod"
      ],
      "role": "historical-owner-input"
    },
    "schema": "ailoot-native-model-representations-v1"
  },
  "schema": "ailoot-static-model-facts-v1",
  "schema_version": 1,
  "shortText": "音声とテキストを受け取り、音声またはテキストで応答するリアルタイム音声対話モデルです。自然な会話のテンポとツールとの連携を想定しています。",
  "source": {
    "audit_sha256": "2e00086bcbfc28e64d0cebe97aa47c17d8d5618963027f8ffb9dc6123d7d25b1",
    "bridge_map_sha256": "1125275768b9636fc8461bc7da5061239a81ddfe508e2557843ca42c58ab0036",
    "raw_model_json_sha256": "6a1a99523b9a57eac29acb5273278b1037cc5e1b5e6c9b20f7597e534e158f68",
    "renderer_sha256": "b06e5309d3e585ab5fe0535c1a8bd6320bdc357ea8509c2389320e8fa40c36e5"
  },
  "sourceRevision": "bc86fe98a51d2d499b2d129dd6a008b8043e2833fa31185ae7a3b4374da26525"
}
