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

Alibaba Cloud Model Studio:Qwen-Omni

最終更新日:Jun 12, 2026

Qwen-Omni モデルは、マルチモーダル入力を受け付け、テキストまたは音声で応答を生成します。人間のような音声を生成し、複数の言語や方言での音声出力をサポートします。ユースケースには、コンテンツモデレーション、テキスト作成、視覚認識、音声ビデオインタラクションなどがあります。

サポートリージョン:シンガポール、北京。ご利用のリージョンの API キー を使用してください。

クイックスタート

前提条件

この例では、テキストプロンプトを Qwen-Omni API に送信し、テキストと音声の両方を含むストリーミング応答を返します。

import os
import base64
import soundfile as sf
import numpy as np
from openai import OpenAI

# 1. クライアントを初期化します
client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),  # 環境変数が設定されていることを確認します
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

# 2. リクエストを送信します
try:
    completion = client.chat.completions.create(
        model="qwen3.5-omni-plus",
        messages=[{"role": "user", "content": "Who are you?"}],
        modalities=["text", "audio"],  # テキストと音声の出力を指定します
        audio={"voice": "Tina", "format": "wav"},
        stream=True,  # True に設定する必要があります
        stream_options={"include_usage": True},
    )

    # 3. ストリーミング応答を処理し、音声をデコードします
    print("Model response:")
    audio_base64_string = ""
    for chunk in completion:
        # テキスト部分を処理します
        if chunk.choices and chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content, end="")

        # 音声部分を収集します
        if chunk.choices and hasattr(chunk.choices[0].delta, "audio") and chunk.choices[0].delta.audio:
            audio_base64_string += chunk.choices[0].delta.audio.get("data", "")

    # 4. 音声ファイルを保存します
    if audio_base64_string:
        wav_bytes = base64.b64decode(audio_base64_string)
        audio_np = np.frombuffer(wav_bytes, dtype=np.int16)
        sf.write("audio_assistant.wav", audio_np, samplerate=24000)
        print("\nAudio file saved to: audio_assistant.wav")

except Exception as e:
    print(f"リクエストに失敗しました: {e}")
// このコードを実行する前に:
// Windows/Mac/Linux の場合:
// 1. Node.js バージョン >= 14 がインストールされていることを確認します。
// 2. 次のコマンドを実行して、必要な依存関係をインストールします:
//    npm install openai wav

import OpenAI from "openai";
import { createWriteStream } from 'node:fs';
import { Writer } from 'wav';

// Base64 文字列を変換し、標準の WAV 音声ファイルとして保存する関数を定義します
async function convertAudio(audioString, audioPath) {
    try {
        // Base64 文字列をバッファにデコードします
        const wavBuffer = Buffer.from(audioString, 'base64');
        // WAV ファイルの書き込みストリームを作成します
        const writer = new Writer({
            sampleRate: 24000,  // サンプルレート
            channels: 1,        // モノラル
            bitDepth: 16        // 16 ビット深度
        });
        // 出力ファイルストリームを作成し、パイプ接続を確立します
        const outputStream = createWriteStream(audioPath);
        writer.pipe(outputStream);

        // PCM データを書き込み、書き込みを終了します
        writer.write(wavBuffer);
        writer.end();

        // Promise を使用して、ファイルの書き込みが完了するのを待ちます
        await new Promise((resolve, reject) => {
            outputStream.on('finish', resolve);
            outputStream.on('error', reject);
        });

        // 音声の整合性を確保するために、追加の待機時間を加えます
        await new Promise(resolve => setTimeout(resolve, 800));

        console.log(`\nAudio file saved to: ${audioPath}`);
    } catch (error) {
        console.error('Error during processing:', error);
    }
}

//  1. クライアントを初期化します
const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);
// 2. リクエストを送信します
const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus",  
    messages: [
        {
            "role": "user",
            "content": "Who are you?"
        }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

let audioString = "";
console.log("Model response:")

// 3. ストリーミング応答を処理し、音声をデコードします
for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        // テキストコンテンツを処理します
        if (chunk.choices[0].delta.content) {
            process.stdout.write(chunk.choices[0].delta.content);
        }
        // 音声コンテンツを処理します
        if (chunk.choices[0].delta.audio) {
            if (chunk.choices[0].delta.audio["data"]) {
                audioString += chunk.choices[0].delta.audio["data"];
            }
        }
    }
}
// 4. 音声ファイルを保存します
convertAudio(audioString, "audio_assistant.wav");
# ======= 重要事項 =======
# シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
# 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。/chat/completions
# === 実行前にこのコメントを削除してください ===

curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-omni-plus",
    "messages": [
        {
            "role": "user", 
            "content": "Who are you?"
        }
    ],
    "stream":true,
    "stream_options":{
        "include_usage":true
    },
    "modalities":["text","audio"],
    "audio":{"voice":"Tina","format":"wav"}
}'

応答

Python または Node.js のコードを実行すると、テキスト応答がコンソールに表示され、audio_assistant.wav という名前のオーディオファイルがコードファイルと同じディレクトリに保存されます。

Model response:
I am a large language model developed by Alibaba Cloud. My name is Qwen. How can I help you?

HTTP コードを実行すると、テキストと Base64 でエンコードされた音声データが、audio フィールドに直接返されます。

data: {"choices":[{"delta":{"content":"I"},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1757647879,"system_fingerprint":null,"model":"qwen3.5-omni-plus","id":"chatcmpl-a68eca3b-c67e-4666-a72f-73c0b4919860"}
data: {"choices":[{"delta":{"content":"am"},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1757647879,"system_fingerprint":null,"model":"qwen3.5-omni-plus","id":"chatcmpl-a68eca3b-c67e-4666-a72f-73c0b4919860"}
......
data: {"choices":[{"delta":{"audio":{"data":"/v8AAAAAAAAAAAAAAA...","expires_at":1757647879,"id":"audio_a68eca3b-c67e-4666-a72f-73c0b4919860"}},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1757647879,"system_fingerprint":null,"model":"qwen3.5-omni-plus","id":"chatcmpl-a68eca3b-c67e-4666-a72f-73c0b4919860"}
data: {"choices":[{"finish_reason":"stop","delta":{"content":""},"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1764763585,"system_fingerprint":null,"model":"qwen3.5-omni-plus","id":"chatcmpl-e8c82e9e-073e-4289-a786-a20eb444ac9c"}
data: {"choices":[],"object":"chat.completion.chunk","usage":{"prompt_tokens":207,"completion_tokens":103,"total_tokens":310,"completion_tokens_details":{"audio_tokens":83,"text_tokens":20},"prompt_tokens_details":{"text_tokens":207}},"created":1757940330,"system_fingerprint":null,"model":"qwen3.5-omni-plus","id":"chatcmpl-9cdd5a26-f9e9-4eff-9dcc-93a878165afc"}

モデルの選択

  • Qwen3.5-Omni シリーズ:長編動画分析、会議の要約、字幕生成、コンテンツモデレーション、音声ビデオインタラクションに最適です。

    • 入力制限:最大 3 時間の音声または 1 時間の動画

    • 音声コントロール:命令による音量、話速、感情の調整をサポート

    • 視覚能力:Qwen3.5 のレベルに匹敵します。画像、音声、効果音、その他のマルチモーダル入力を理解します

    • 複合マルチモーダル入力:1 つのリクエストで、テキストと画像、音声、動画の任意の組み合わせをサポートします

    • 複合マルチモーダル入力は、Qwen3.5-Omni シリーズでのみサポートされています。 1 つのリクエストで、イメージ、オーディオ、テキスト、またはビデオ、イメージ、テキストなど、複数のモダリティを任意に組み合わせてデータを提供できます。

  • Qwen3-Omni-Flash シリーズ:短編動画分析やコストに敏感なシナリオに最適です。

    • 入力制限:音声と動画の入力は最大 150 秒

    • 思考モード:思考モードをサポートする唯一の Qwen-Omni シリーズモデル

    • 入力モダリティ:テキストと他の単一モダリティ (画像、音声、または動画) の組み合わせのみをサポートします。

  • Qwen-Omni-Turbo シリーズ

    このシリーズは更新されなくなり、機能も限定されています。Qwen3.5-Omni または Qwen3-Omni-Flash シリーズへの移行を推奨します。

シリーズ

音声・動画の説明

ディープシンキング

入力音声言語

出力音声言語

サポートされている音声

Qwen3.5-Omni

最新世代のオムニモーダルモデル

強力

非サポート

113

74 の言語と 39 の方言

言語:中国語、英語、ドイツ語、フランス語、イタリア語、チェコ語、インドネシア語、タイ語、韓国語、ポーランド語、日本語、ベトナム語、フィンランド語、ポルトガル語、スペイン語、オランダ語、ロシア語、マレー語、カタルーニャ語、スウェーデン語、トルコ語、ウクライナ語、ルーマニア語、スロバキア語、デンマーク語、アイスランド語、ノルウェー語 (ブークモール)、マケドニア語、ギリシャ語、ハンガリー語、ガリシア語、フィリピン語、クロアチア語、ボスニア語、スロベニア語、ブルガリア語、カザフ語、ベラルーシ語、ラトビア語、エストニア語、アゼルバイジャン語、ウイグル語、スワヒリ語、ヒンディー語、エスペラント語、キルギス語、タジク語、セブアノ語、アフリカーンス語、アラビア語、リトアニア語、ジャワ語、ベンガル語、ペルシャ語、ヘブライ語、パンジャブ語、グジャラート語、モンゴル語、アストゥリアス語、カンナダ語、マラーティー語、インターリングア、マラヤーラム語、マルタ語、ノルウェー語ニーノシュク、テルグ語、ウルドゥー語、グルジア語、バスク語、タミル語、オリヤー語、セルビア語、マオリ語

方言:
東北官話、貴州方言、広東語、河南方言、香港広東語、上海語、陝西省方言、天津方言、台湾閩南語、雲南省方言、安徽省方言、福建省方言、甘粛省方言、広東省方言、湖北省方言、湖南省方言、江西省方言、山東省方言、山西省方言、四川省方言、広西チワン族自治区方言、海南語、重慶方言、長沙方言、杭州方言、合肥方言、銀川方言、鄭州方言、瀋陽方言、温州語、武漢方言、昆明方言、太原方言、南昌方言、済南方言、蘭州方言、南京方言、客家語、閩南語

... (many
tags) ...



36

29 の言語と 7 の方言

言語:中国語、英語、ドイツ語、イタリア語、ポルトガル語、スペイン語、日本語、韓国語、フランス語、ロシア語、タイ語、インドネシア語、アラビア語、ベトナム語、トルコ語、フィンランド語、ポーランド語、ヒンディー語、オランダ語、チェコ語、ウルドゥー語、タガログ語、スウェーデン語、デンマーク語、ヘブライ語、アイスランド語、マレー語、ノルウェー語、ペルシャ語

方言:四川方言、北京方言、天津方言、南京方言、陝西方言、広東語、閩南語

55

Qwen3-Omni-Flash

ハイブリッド思考モデル

比較的弱い

サポート

19

11 の言語と 8 の方言

言語:

中国語、英語、ドイツ語、フランス語、イタリア語、タイ語、韓国語、日本語、ロシア語、スペイン語、ポルトガル語

方言:

四川方言、上海語、広東語、閩南語、陝西方言、南京方言、天津方言、北京方言

19

11 の言語と 8 の方言

言語:

中国語、英語、ドイツ語、フランス語、イタリア語、タイ語、韓国語、日本語、ロシア語、スペイン語、ポルトガル語

方言:

四川語、上海語、広東語、福建語、陝西方言、南京方言、天津方言、北京方言

17~49

バージョンによって異なります

Qwen-Omni-Turbo

更新停止

なし

非サポート

中国語、英語

中国語、英語

4

モデル名、コンテキストウィンドウ、価格、スナップショットバージョンについては、Model Studio コンソールでご確認ください。レート制限については、「レート制限」をご参照ください。

モデルのパフォーマンス

音声・動画コンテンツ分析

この動画のタイムスタンプ付きの詳細な説明を生成してください。

00:00.000 – 00:02.500

雨に濡れた街の通りがワイドスクリーンのフレームいっぱいに広がる。長時間露光撮影により、濡れた舗道に赤と青の車のライトが筋状に伸びている。暗い膝丈のトレンチコートと明るいシャツにネクタイを締めた一人の男が、右側の歩道をカメラに向かって歩いてくる。雨粒が彼の肩と髪に付着している。一歩ごとに、湿ったコンクリートの上でくぐもった音がする。低く不吉な電子音のハミングが環境音の下に響き、絶え間なく降る雨が周囲でパチパチと音を立てる。彼の横のレンガの壁はカラフルなグラフィティで覆われ、遠くにはネオンサインが光っている。1 つはオレンジがかった赤の筆記体で「Nice」とはっきりと表示され、もう 1 つの縦長のサインは下部に「AT」の文字が見える。

......

00:12.300 – 00:14.533

カメラが下に傾く。懐中電灯の光の中で、黄ばんで古びた一枚の紙が浅い水たまりに横たわっており、その端は焦げ、角は丸まっている。インクで書かれた段落がその表面のほとんどを覆っているが、湿気と焦げ跡でテキストは判読不能である。男はひざまずき、手袋をはめた指をドキュメントに向かって伸ばす。彼の手が近づくにつれて、波紋が外側に広がる。サイレンの音がピークに達した後、わずかに遠ざかり始めるが、環境音のハミングは一定のままである。震える紙に触れる直前でシーンはフリーズし、クリップは終了する。

一部のタイムスタンプのみ表示されています。

多方言理解

異なる中国語の方言を話す歌手の声の特徴、感情状態、および完全な歌詞を記述してください。

この音声は、中国のさまざまな地域の歌手によるラップパフォーマンスを特集しており、豊かな方言の多様性を示しています。以下は、各歌手の声の特徴、感情状態、および対応する歌詞の詳細な説明です:

杭州方言 (呉語)

声の特徴:

男性歌手の声は柔らかく穏やかで、呉語特有の滑らかさと温かみがあります。彼のイントネーションは穏やかに上下し、リズムは軽快で速く、リラックスした語り口の効果を生み出しています。

感情状態:

リラックスして快適で、日常生活に満ちています。彼は杭州のゆったりとしたライフスタイルと都市の変化を描写し、故郷への愛情と現代の発展についての考察を表現しています。全体的に、彼は居心地が良く、親しみやすいと感じています。

歌詞:

> 杭州方言、よく聞いて!私たちの文化には、地元の児化音の発音が含まれています。

> 西湖のほとりに咲く花のように、文化調査は必要ありません。私たちが一番よく理解しています。

> あなたたちは誰も理解していません。「三不打門」、「哥儿」、「老儿」、「份儿」、「丫儿」...部外者がこれらをどうやって見分けることができるでしょうか?

> 行こう!交通は速い。どこにでも地下鉄がある。確認してみよう。

> 東南アジアとタイを歓迎し、「十三太」のショーを見る。私たちの街を誇りに思い、性格は率直です。

> あなたは「橋渡り」の経験のためだけに来て、味が違うから帰らないのですか?

一部の結果のみ表示されています。

歌詞字幕生成

歌詞を書き起こし、各行にこのフォーマットでタイムスタンプを付けてください:[00:00:15,020 --> 00:00:28,085] : When you walk through a storm, hold your head up high.[00:00:28,085 --> 00:00:40,200] And don't be afraid of the dark. ......

[00:00:12,680 --> 00:00:16,960] 猫の糸が木々の月明かりをかすめて揺れる。

[00:00:18,400 --> 00:00:22,800] ラジエーターが 1998 年のチャートヒットをハミングする。

[00:00:24.160 → 00:00:28.080] 時間が霧のような熱波を分ける。

[00:00:28,920 --> 00:00:33,000] 画面からのネオンが私の鼻筋を照らす。

......

[00:03:16,720 --> 00:03:21,680] 私たちは木の幹の最も柔らかい輪の中に寄り添う。

[00:03:22,400 --> 00:03:27,000] 呼吸が残りの暖かさを蜂蜜砂糖に変える。

[00:03:28,160 --> 00:03:33,200] ソファが雲のようなふわふわの形に沈む。

[00:03:34,000 --> 00:03:38,800] すべての毛穴が太陽の光を吸収する。

[00:04:09,000 --> 00:04:10,020] (終了)

一部の結果のみ表示されています。

音声・動画プログラミング

使用方法

ストリーミング出力

Qwen-Omni へのすべてのリクエストは stream=True をセットする必要があります。

モデル構成

コスト、速度、品質のバランスをとるために、パラメーター、プロンプト、メディアの長さを構成します。

音声・動画理解

ユースケース

推奨動画長

推奨プロンプト

推奨 max_pixels

高速レビュー、低コスト

≤60 分

50 ワード以内の簡単なプロンプト

230,400

コンテンツ抽出 (長編動画のセグメンテーション)

≤60 分

921,600~2,073,600

標準分析 (短編動画のタグ付け)

≤4 分

以下の構造化プロンプトを使用してください

推奨プロンプト

Provide a detailed description of the video.
It should explicitly include three sections: 
1. A structured chronological storyline of **every noticeable audio and visual detail**
2. A structured list of all visible text. For each text element, include start timestamp, end timestamp, the exact text content, and the appearance characteristics. If no text appears, explicitly state so.
3. A structured speech-to-text transcription, include speaker (corresponding to the character or voice‑over in Section 1, including their accent and tone), exact spoken content, start timestamp, end timestamp, and speaking state (prosody, emotion, and style). If no speech appears, explicitly state so.
Aside from these three required sections, you are free to organize any additional content in any way you find helpful. This additional content can include global information about the entire video or localized information about specific moments. You may choose the topic of this extra content freely.
Output Format:
```
## Storyline
<xx:xx.xxx> - <xx:xx.xxx>
<an unstructured long paragraph in natural language describing what happened during this period, blending both audio and video details.>
<xx:xx.xxx> - <xx:xx.xxx>
<an unstructured long paragraph in natural language describing what happened during this period, blending both audio and video details.>
<xx:xx.xxx> - <xx:xx.xxx>
<an unstructured long paragraph in natural language describing what happened during this period, blending both audio and video details.>
...
## Visible Text
<xx:xx.xxx> - <xx:xx.xxx>
“<element>”: <appearance>
“<element>”: <appearance>
<xx:xx.xxx> - <xx:xx.xxx>
“<element>”: <appearance>
“<element>”: <appearance>
“<element>”: <appearance>
<xx:xx.xxx> - <xx:xx.xxx>
“<element>”: <appearance>
...
## Speakers and Transcript
Speaker profiles:
<speaker> - <profile>
<speaker> - <profile>
<speaker> - <profile>
...
<xx:xx.xxx> - <xx:xx.xxx>
Speaker: <speaker>
State: <description>
Content: “<content>”
<xx:xx.xxx> - <xx:xx.xxx>
Speaker: <speaker>
State: <description>
Content: “<content>”
<xx:xx.xxx> - <xx:xx.xxx>
Speaker: <speaker>
State: <description>
Content: “<content>”
...
## <another section>
<paragraphs>
## <another section>
<paragraphs>
...
```

921,600~2,073,600

詳細な分析 (複数の話者/複雑なシーン)

≤2 分

2,073,600

説明

最初に長編動画をセグメント化して、詳細な説明を取得できます。

音声理解

音声の長さとプロンプトの複雑さを制御することで、コストと品質のバランスをとることができます。

ユースケース

推奨音声長

推奨プロンプト

高速レビュー、低コスト

≤60 分

50 ワード以内の簡単なプロンプト

コンテンツ抽出 (長編音声のセグメント化)

≤60 分

標準分析 (音声タグ付け)

≤2 分

構造化プロンプトを使用

構造化プロンプト

Provide a detailed description of the audio.

It should explicitly include two sections: 

1. A structured chronological storyline of **every noticeable audio detail**
2. A structured speech-to-text transcription, include speaker (Corresponding to the character or voice‑over in Section 1, including their accent and tone), exact spoken content, start timestamp, end timestamp, and speaking state (prosody, emotion, and style). If no speech appears, explicitly state so.

Aside from these two required components, you are free to organize any additional content in any way you find helpful. This additional content can include global information about the entire audio or localized information about specific moments. You may choose the topic of this extra content freely.

Output Format:

```
## Storyline

<xx:xx.xxx> - <xx:xx.xxx>
<an unstructured long paragraph in natural language describing what happened during this period, blending both audio details.>

<xx:xx.xxx> - <xx:xx.xxx>
<an unstructured long paragraph in natural language describing what happened during this period, blending both audio details.>

<xx:xx.xxx> - <xx:xx.xxx>
<an unstructured long paragraph in natural language describing what happened during this period, blending both audio details.>

...

...

## Speakers and Transcript

Speaker profiles:
<speaker> - <profile>
<speaker> - <profile>
<speaker> - <profile>
...

<xx:xx.xxx> - <xx:xx.xxx>
Speaker: <speaker>
State: <description>
Content: “<content>”

<xx:xx.xxx> - <xx:xx.xxx>
Speaker: <speaker>
State: <description>
Content: “<content>”

<xx:xx.xxx> - <xx:xx.xxx>
Speaker: <speaker>
State: <description>
Content: “<content>”

...

## <another section>

<paragraphs>

## <another section>

<paragraphs>

...
```

詳細な分析 (複数の話者/複雑なシーン)

≤1 分

説明

最初に長編音声をセグメント化して、詳細な説明を取得できます。

複合マルチモーダル入力

説明

複合マルチモーダル入力は、Qwen3.5-Omni シリーズでのみサポートされています。画像、音声、テキストの任意の組み合わせ、または動画、画像、テキストなど、複数のモダリティのデータを同じリクエストで提供できます。

次の例は、マルチモーダル分析のために 1 つのリクエストで画像と音声を提供する方法を示しています。

OpenAI 互換

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241022/emyrja/dog_and_girl.jpeg"
                    },
                },
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20250211/tixcef/cherry.wav",
                        "format": "wav"
                    },
                },
                {"type": "text", "text": "Describe the image content and tell me what the audio is about."},
            ],
        },
    ],
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);

const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus",
    messages: [
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": { "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241022/emyrja/dog_and_girl.jpeg" },
                },
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20250211/tixcef/cherry.wav",
                        "format": "wav"
                    },
                },
                { "type": "text", "text": "Describe the image content and tell me what the audio is about." }
            ]
        }
    ],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}
# シンガポールリージョンと北京リージョンの API キーは異なります。 API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
# 次の URL はシンガポールリージョン用です。 呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。 URL はリージョンによって異なります。/chat/completions

curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-omni-plus",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
                    }
                },
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250211/tixcef/cherry.wav",
                        "format": "wav"
                    }
                },
                {
                    "type": "text",
                    "text": "イメージの内容を説明し、音声が何についてのものか教えてください。"
                }
            ]
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    },
    "modalities": ["text", "audio"],
    "audio": {"voice": "Tina", "format": "wav"}
}'

単一モダリティ入力

各リクエストには、テキストと他の 1 つのモダリティ (動画、音声、または画像) が含まれます。すべての Qwen-Omni モデルがこれをサポートしています。

動画とテキストの入力

動画を画像リストまたは動画ファイル (音声サポート付き) として提供します。

動画ファイル (動画内の音声をサポート)

  • ファイル数:

    • Qwen3.5-Omni シリーズ:パブリック URL を使用して最大 512 ファイル、Base64 エンコーディングを使用して最大 250 ファイル。

    • Qwen3-Omni-Flash および Qwen-Omni-Turbo シリーズ:1 ファイルのみ許可されます。

  • ファイルサイズ:

    • パブリック URL の使用:

      • Qwen3.5-Omni シリーズ:最大 2 GB

      • Qwen3-Omni-Flash:最大 256 MB

      • Qwen-Omni-Turbo:最大 150 MB

    • Base64 エンコーディングの使用:エンコードされた Base64 文字列は 10 MB 未満である必要があります

  • 持続時間制限:

    • Qwen3.5-Omni シリーズ:1 時間

    • Qwen3-Omni-Flash:150 秒

    • Qwen-Omni-Turbo:40 秒

  • ファイル形式:MP4、AVI、MKV、MOV、FLV、WMV。

  • 動画ファイル内の視覚情報と音声情報は別々に課金されます。

OpenAI 互換

import os
from openai import OpenAI

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus", # Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "video_url",
                    "video_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241115/cqqkru/1.mp4"
                    },
                },
                {"type": "text", "text": "What is the video about?"},
            ],
        },
    ],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンの API キーは異なります。 API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。 呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。 URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);
const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus", // Qwen3-Omni-Flash の場合、ノンシンキングモードで実行します。
    messages: [
        {
            "role": "user",
            "content": [{
                "type": "video_url",
                "video_url": { "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4" },
            },
            { "type": "text", "text": "What is the video about?" }]
        }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});


for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}
# ======= 重要事項 =======
# シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
# 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。/chat/completions
# === 実行前にこのコメントを削除してください ===

curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-omni-plus",
    "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "video_url",
          "video_url": {
            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241115/cqqkru/1.mp4"
          }
        },
        {
          "type": "text",
          "text": "What is the video about"
        }
      ]
    }
  ],
    "stream":true,
    "stream_options": {
        "include_usage": true
    },
    "modalities":["text","audio"],
    "audio":{"voice":"Tina","format":"wav"}
}'

画像リスト形式

画像数

  • Qwen3.5-Omni シリーズ:最小 2 枚、最大 2048 枚

  • Qwen3-Omni-Flash:最小 2 枚、最大 128 枚

  • Qwen-Omni-Turbo:最小 4 枚、最大 80 枚

OpenAI 互換

import os
from openai import OpenAI

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus", # Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "video",
                    "video": [
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/xzsgiz/football1.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/tdescd/football2.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/zefdja/football3.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/aedbqh/football4.jpg",
                    ],
                },
                {"type": "text", "text": "Describe the process shown in this video"},
            ],
        }
    ],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンの API キーは異なります。 API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。 呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。 URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);
const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus", // Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages: [{
        role: "user",
        content: [
            {
                type: "video",
                video: [
                    "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
                    "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
                    "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
                    "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"
                ]
            },
            {
                type: "text",
                text: "このビデオに映っているプロセスを説明してください"
            }
        ]
    }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}
# ======= 重要事項 =======
# シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
# 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。/chat/completions
# === 実行前にこのコメントを削除してください ===

curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-omni-plus",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "video",
                    "video": [
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/xzsgiz/football1.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/tdescd/football2.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/zefdja/football3.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/aedbqh/football4.jpg"
                    ]
                },
                {
                    "type": "text",
                    "text": "Describe the process shown in this video"
                }
            ]
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    },
    "modalities": ["text", "audio"],
    "audio": {
        "voice": "Tina",
        "format": "wav"
    }
}'

音声とテキストの入力

  • ファイル数:

    • Qwen3.5-Omni シリーズ:パブリック URL を使用して最大 2048 ファイル、Base64 エンコーディングを使用して最大 250 ファイル。

    • Qwen3-Omni-Flash および Qwen-Omni-Turbo シリーズ:1 ファイルのみ許可されます。

  • ファイルサイズ:

    • パブリック URL の使用:

      • Qwen3.5-Omni シリーズ:最大 2 GB

      • Qwen3-Omni-Flash:最大 100 MB

      • Qwen-Omni-Turbo:最大 10 MB

    • Base64 エンコーディングの使用:エンコードされた Base64 文字列は 10 MB 未満である必要があります

  • 持続時間制限:

    • Qwen3.5-Omni シリーズ:最大 3 時間

    • Qwen3-Omni-Flash:最大 20 分

    • Qwen-Omni-Turbo:最大 3 分

  • ファイル形式:AMR、WAV、3GP、3GPP、AAC、MP3。

この例では、パブリック音声 URL を使用します。ローカルファイルを使用するには、「Base64 エンコーディングでローカルファイルを送信」をご参照ください。呼び出しではストリーミング出力のみがサポートされています。

OpenAI 互換

import os
from openai import OpenAI

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus",# Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20250211/tixcef/cherry.wav",
                        "format": "wav",
                    },
                },
                {"type": "text", "text": "What is this audio about"},
            ],
        },
    ],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);
const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus", // Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages: [
        {
            "role": "user",
            "content": [{
                "type": "input_audio",
                "input_audio": { "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20250211/tixcef/cherry.wav", "format": "wav" },
            },
            { "type": "text", "text": "What is this audio about" }]
        }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}
# ======= 重要な注意点 =======
# シンガポールリージョンと北京リージョンの API キーは異なります。API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
# 以下の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。/chat/completions
# === 実行前にこのコメントを削除してください ===

curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-omni-plus",
    "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_audio",
          "input_audio": {
            "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250211/tixcef/cherry.wav",
            "format": "wav"
          }
        },
        {
          "type": "text",
          "text": "What is this audio about"
        }
      ]
    }
  ],
    "stream":true,
    "stream_options":{
        "include_usage":true
    },
    "modalities":["text","audio"],
    "audio":{"voice":"Tina","format":"wav"}
}'

画像とテキストの入力

Qwen-Omni モデルは、リクエストごとに複数の画像をサポートします。画像の要件:

  • 画像数:

    • パブリック URL の使用:最大 2048 枚

    • Base64 エンコーディングの使用:最大 250 枚

  • 画像サイズ:

    • パブリック URL の使用:

      • Qwen3.5-Omni シリーズ:各画像ファイルは 20 MB を超えてはなりません

      • Qwen3-Omni-Flash および Qwen-Omni-Turbo シリーズ:各画像ファイルは 10 MB を超えてはなりません

    • Base64 エンコーディングの使用:エンコードされた Base64 文字列は 10 MB 未満である必要があります。

  • 幅と高さの両方が 10 ピクセルを超える必要があります。縦横比は 200:1 または 1:200 を超えてはなりません。

  • サポートされている画像タイプ:詳細については、「画像と動画の理解」をご参照ください。

この例では、パブリック画像 URL を使用します。ローカルファイルを使用するには、「Base64 エンコードされたローカルファイルの入力」をご参照ください。ストリーミング出力が必要です。

OpenAI 互換

import os
from openai import OpenAI

client = OpenAI(
    # シンガポールリージョンと北京リージョンの API キーは異なります。API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出す際、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンごとに異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus", # Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
                    },
                },
                {"type": "text", "text": "What scene is depicted in the image?"},
            ],
        },
    ],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています。
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。設定しない場合、エラーが発生します。
    stream=True,
    stream_options={
        "include_usage": True
    }
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);
const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus", // Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages: [
        {
            "role": "user",
            "content": [{
                "type": "image_url",
                "image_url": { "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241022/emyrja/dog_and_girl.jpeg" },
            },
            { "type": "text", "text": "What scene is depicted in the image?" }]
        }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}
# ======= 重要事項 =======
# シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
# 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。/chat/completions
# === 実行前にこのコメントを削除してください ===


curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-omni-plus",
    "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "image_url",
          "image_url": {
            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241022/emyrja/dog_and_girl.jpeg"
          }
        },
        {
          "type": "text",
          "text": "What scene is depicted in the image?"
        }
      ]
    }
  ],
    "stream":true,
    "stream_options":{
        "include_usage":true
    },
    "modalities":["text","audio"],
    "audio":{"voice":"Tina","format":"wav"}
}'

Web 検索

Qwen3.5-Omni シリーズは、Web 検索をサポートしてリアルタイム情報を取得し、推論を実行します。

  • ウェブ検索は Qwen3.5-Omni シリーズでのみサポートされています。search_strategy パラメーターには agent のみを指定できます。

  • 課金については、課金agent ポリシーをご参照ください。

Web 検索を有効にするには、enable_searchsearch_strategyagent に設定します:

OpenAI 互換

# 前提条件:
# pip install openai

import os
from openai import OpenAI

# クライアントを初期化します
client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

# リクエストを送信します (Web 検索を有効)
try:
    completion = client.chat.completions.create(
        model="qwen3.5-omni-plus",
        messages=[{
            "role": "user", 
            "content": "What is today's date and day of the week, and what important holidays are there today?"
        }],
        stream=True,
        stream_options={"include_usage": True},
        # Web 検索を有効にします
        extra_body={
            "enable_search": True
        }
    )
    
    print("モデルの応答 (リアルタイム情報あり):")
    for chunk in completion:
        if chunk.choices and chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content, end="")
    print()
    
except Exception as e:
    print(f"リクエストに失敗しました:{e}")
// 前提条件:
// npm install openai

import OpenAI from "openai";

// クライアントを初期化します
const openai = new OpenAI({
    // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    apiKey: process.env.DASHSCOPE_API_KEY,
    // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
});

// リクエストを送信します (Web 検索を有効)
const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus",
    messages: [{
        "role": "user",
        "content": "What is today's date and day of the week, and what important holidays are there today?"
    }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    // Web 検索を有効にします
    extra_body: {
        enable_search: true
    }
});

console.log("モデルの応答 (リアルタイム情報あり):");

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        if (chunk.choices[0].delta.content) {
            process.stdout.write(chunk.choices[0].delta.content);
        }
    }
}
console.log();
# ======= 重要 =======
# シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
# 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。/chat/completions
# === 実行前にこのコメントを削除してください ===

curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3.5-omni-plus",
    "messages": [
        {
            "role": "user", 
            "content": "What is today's date and day of the week, and what important holidays are there today?"
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    },
    "enable_search": true
}'

思考モードの有効化/無効化

Qwen-Omni シリーズでは、Qwen3-Omni-Flash モデルのみがハイブリッド思考モデルです。enable_thinking パラメーターを使用して、思考モードを有効化または無効化できます:

  • true

  • false (デフォルト)

思考モードでは、音声出力はサポートされていません。

OpenAI 互換

import os
from openai import OpenAI

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3-omni-flash",
    messages=[{"role": "user", "content": "Who are you?"}],

    # 思考モードを有効または無効にします。思考モードでは音声出力はサポートされていません。Qwen-Omni-Turbo は enable_thinking をサポートしていません。
    extra_body={'enable_thinking': True},

    # 出力モダリティを設定します。ノンシンキングモードでは ["text","audio"] と ["text"] の 2 つのオプションがサポートされています。思考モードでは ["text"] のみがサポートされています。
    modalities=["text"],

    # 音声を設定します。audio パラメーターは思考モードではサポートされていません。
    # audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);
const completion = await openai.chat.completions.create({
    model: "qwen3-omni-flash",
    messages: [
        { role: "user", content: "Who are you?" }
    ],

    // stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream: true,
    stream_options: {
        include_usage: true
    },
    // 思考モードを有効または無効にします。思考モードでは音声出力はサポートされていません。Qwen-Omni-Turbo は enable_thinking をサポートしていません。
    extra_body:{'enable_thinking': true},
    //  出力モダリティを設定します。ノンシンキングモードでは ["text","audio"] と ["text"] の 2 つのオプションがサポートされています。思考モードでは ["text"] のみがサポートされています。
    modalities: ["text"],
    // 音声を設定します。audio パラメーターは思考モードではサポートされていません。
    //audio: { voice: "Tina", format: "wav" }
});

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}
# ======= 重要事項 =======
# シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
# 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。/chat/completions
# === 実行前にこのコメントを削除してください ===

curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen3-omni-flash",
    "messages": [
        {
            "role": "user",
            "content": "Who are you?"
        }
    ],
    "stream":true,
    "stream_options":{
        "include_usage":true
    },
    "modalities":["text"],
    "enable_thinking": true
}'

応答

data: {"choices":[{"delta":{"content":null,"role":"assistant","reasoning_content":""},"index":0,"logprobs":null,"finish_reason":null}],"object":"chat.completion.chunk","usage":null,"created":1757937336,"system_fingerprint":null,"model":"qwen3-omni-flash","id":"chatcmpl-ce3d6fe5-e717-4b7e-8b40-3aef12288d4c"}
data: {"choices":[{"finish_reason":null,"logprobs":null,"delta":{"content":null,"reasoning_content":"Hmm"},"index":0}],"object":"chat.completion.chunk","usage":null,"reated":1757937336,"system_fingerprint":null,"model":"qwen3-omni-flash","id":"chatcmpl-ce3d6fe5-e717-4b7e-8b40-3aef12288d4c"}
data: {"choices":[{"delta":{"content":null,"reasoning_content":","},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"reated":1757937336,"system_fingerprint":null,"model":"qwen3-omni-flash","id":"chatcmpl-ce3d6fe5-e717-4b7e-8b40-3aef12288d4c"}
......
data: {"choices":[{"delta":{"content":"Tell me"},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1757937336,"tem_fingerprint":null,"model":"qwen3-omni-flash","id":"chatcmpl-ce3d6fe5-e717-4b7e-8b40-3aef12288d4c"}
data: {"choices":[{"delta":{"content":"!"},"finish_reason":null,"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1757937336,"systm_fingerprint":null,"model":"qwen3-omni-flash","id":"chatcmpl-ce3d6fe5-e717-4b7e-8b40-3aef12288d4c"}
data: {"choices":[{"finish_reason":"stop","delta":{"content":"","reasoning_content":null},"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1757937336,"system_fingerprint":null,"model":"qwen3-omni-flash","id":"chatcmpl-ce3d6fe5-e717-4b7e-8b40-3aef12288d4c"}
data: {"choices":[],"object":"chat.completion.chunk","usage":{"prompt_tokens":11,"completion_tokens":363,"total_tokens":374,"completion_tokens_details":{"reasoning_tokens":195,"text_tokens":168},"prompt_tokens_details":{"text_tokens":11}},"created":1757937336,"system_fingerprint":null,"model":"qwen3-omni-flash","id":"chatcmpl-ce3d6fe5-e717-4b7e-8b40-3aef12288d4c"}

マルチターン対話

Qwen-Omni モデルをマルチターン対話で使用する場合、次の点にご注意ください:

  • アシスタントメッセージ

    messages 配列のアシスタントメッセージには、テキストデータのみを含めることができます。

  • ユーザーメッセージ

    ユーザーメッセージには、テキストと他の 1 つのモダリティを含めることができます。マルチターン対話では、異なるユーザーメッセージで異なるモダリティを入力できます。

OpenAI 互換

import os
from openai import OpenAI

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus", # Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/welcome.mp3",
                        "format": "mp3",
                    },
                },
                {"type": "text", "text": "What is this audio about"},
            ],
        },
        {
            "role": "assistant",
            "content": [{"type": "text", "text": "This audio says: Welcome to Alibaba Cloud"}],
        },
        {
            "role": "user",
            "content": [{"type": "text", "text": "Tell me about this company."}],
        },
    ],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています
    modalities=["text"],
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);
const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus", // Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages: [
        {
            "role": "user",
            "content": [
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/welcome.mp3",
                        "format": "mp3",
                    },
                },
                { "type": "text", "text": "What is this audio about" },
            ],
        },
        {
            "role": "assistant",
            "content": [{ "type": "text", "text": "This audio says: Welcome to Alibaba Cloud" }],
        },
        {
            "role": "user",
            "content": [{ "type": "text", "text": "Tell me about this company." }]
        }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text"]
});


for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}
# ======= 重要事項 =======
# シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
# 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。/chat/completions
# === 実行前にこのコメントを削除してください ===

curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "model": "qwen3.5-omni-plus",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_audio",
          "input_audio": {
            "data": "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/welcome.mp3"
          }
        },
        {
          "type": "text",
          "text": "What is this audio about"
        }
      ]
    },
    {
      "role": "assistant",
      "content": [
        {
          "type": "text",
          "text": "This audio says: Welcome to Alibaba Cloud"
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Tell me about this company."
        }
      ]
    }
  ],
  "stream": true,
  "stream_options": {
    "include_usage": true
  },
  "modalities": ["text"]
}'

Base64 エンコードされた出力音声データの解析

Qwen-Omni モデルは、音声をストリーミング Base64 エンコードデータとして出力します。生成中に、文字列変数を維持し、返された各チャンクからの Base64 エンコードデータを追加します。生成が完了したら、完全な文字列を Base64 デコードして音声ファイルを取得します。または、各チャンクをリアルタイムでデコードして再生することもできます。

# pyaudio のインストール手順:
# APPLE Mac OS X
#   brew install portaudio
#   pip install pyaudio
# Debian/Ubuntu
#   sudo apt-get install python-pyaudio python3-pyaudio
#   or
#   pip install pyaudio
# CentOS
#   sudo yum install -y portaudio portaudio-devel && pip install pyaudio
# Microsoft Windows
#   python -m pip install pyaudio

import os
from openai import OpenAI
import base64
import numpy as np
import soundfile as sf

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus", # Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[{"role": "user", "content": "Who are you?"}],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

# 方法 1:生成完了後にデコード
audio_string = ""
for chunk in completion:
    if chunk.choices:
        if hasattr(chunk.choices[0].delta, "audio"):
            try:
                audio_string += chunk.choices[0].delta.audio["data"]
            except Exception as e:
                print(chunk.choices[0].delta.content)
    else:
        print(chunk.usage)

wav_bytes = base64.b64decode(audio_string)
audio_np = np.frombuffer(wav_bytes, dtype=np.int16)
sf.write("audio_assistant_py.wav", audio_np, samplerate=24000)

# 方法 2:生成中にデコード (方法 2 を使用するには、方法 1 のコードをコメントアウトします)
# # PyAudio を初期化します
# import pyaudio
# import time
# p = pyaudio.PyAudio()
# # 音声ストリームを作成します
# stream = p.open(format=pyaudio.paInt16,
#                 channels=1,
#                 rate=24000,
#                 output=True)

# for chunk in completion:
#     if chunk.choices:
#         if hasattr(chunk.choices[0].delta, "audio"):
#             try:
#                 audio_string = chunk.choices[0].delta.audio["data"]
#                 wav_bytes = base64.b64decode(audio_string)
#                 audio_np = np.frombuffer(wav_bytes, dtype=np.int16)
#                 # 音声データを直接再生します
#                 stream.write(audio_np.tobytes())
#             except Exception as e:
#                 print(chunk.choices[0].delta.content)

# time.sleep(0.8)
# # リソースをクリーンアップします
# stream.stop_stream()
# stream.close()
# p.terminate()
// 実行前:
// Windows/Mac/Linux の場合:
// 1. Node.js バージョン >= 14 がインストールされていることを確認します。
// 2. 次のコマンドを実行して、必要な依存関係をインストールします:
//    npm install openai wav
// 
// リアルタイム再生機能 (方法 2) を使用するには、以下も必要です:
// Windows:
//    npm install speaker
// Mac:
//    brew install portaudio
//    npm install speaker
// Linux (Ubuntu/Debian):
//    sudo apt-get install libasound2-dev
//    npm install speaker

import OpenAI from "openai";

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);
const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus", // Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages: [
        {
            "role": "user",
            "content": "Who are you?"
        }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

// 方法 1:生成完了後にデコード
// インストールが必要です: npm install wav
import { createWriteStream } from 'node:fs';  // node:fs は Node.js の組み込みモジュールであり、インストールは不要です
import { Writer } from 'wav';

async function convertAudio(audioString, audioPath) {
    try {
        // Base64 文字列をバッファにデコードします
        const wavBuffer = Buffer.from(audioString, 'base64');
        // WAV ファイルの書き込みストリームを作成します
        const writer = new Writer({
            sampleRate: 24000,  // サンプルレート
            channels: 1,        // モノラル
            bitDepth: 16        // 16 ビット深度
        });
        // 出力ファイルストリームを作成し、パイプ接続を確立します
        const outputStream = createWriteStream(audioPath);
        writer.pipe(outputStream);

        // PCM データを書き込み、書き込みを終了します
        writer.write(wavBuffer);
        writer.end();

        // Promise を使用して、ファイルの書き込みが完了するのを待ちます
        await new Promise((resolve, reject) => {
            outputStream.on('finish', resolve);
            outputStream.on('error', reject);
        });

        // 音声の整合性を確保するために、追加の待機時間を加えます
        await new Promise(resolve => setTimeout(resolve, 800));

        console.log(`Audio file successfully saved as ${audioPath}`);
    } catch (error) {
        console.error('An error occurred during processing:', error);
    }
}

let audioString = "";
for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        if (chunk.choices[0].delta.audio) {
            if (chunk.choices[0].delta.audio["data"]) {
                audioString += chunk.choices[0].delta.audio["data"];
            }
        }
    } else {
        console.log(chunk.usage);
    }
}
// 変換を実行します
convertAudio(audioString, "audio_assistant_mjs.wav");


// 方法 2:リアルタイムで生成して再生します
// 上記のシステムの手順に従って、必要なコンポーネントをインストールします。
// import Speaker from 'speaker'; // 音声再生ライブラリをインポートします

// // スピーカーインスタンスを作成します (構成は WAV ファイルのパラメーターと一致します)
// const speaker = new Speaker({
//     sampleRate: 24000,  // サンプルレート
//     channels: 1,        // サウンドチャンネル数
//     bitDepth: 16,       // ビット深度
//     signed: true        // 符号付き PCM
// });
// for await (const chunk of completion) {
//     if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
//         if (chunk.choices[0].delta.audio) {
//             if (chunk.choices[0].delta.audio["data"]) {
//                 const pcmBuffer = Buffer.from(chunk.choices[0].delta.audio.data, 'base64');
//                 // 再生のためにスピーカーに直接書き込みます
//                 speaker.write(pcmBuffer);
//             }
//         }
//     } else {
//         console.log(chunk.usage);
//     }
// }
// speaker.on('finish', () => console.log('Playback complete'));
// speaker.end(); // API ストリームの実際の終了に基づいて呼び出します

Base64 エンコードされたローカルファイルの入力

Base64 エンコーディングを使用してファイルを送信する場合、エンコードされた Base64 文字列は 10 MB 未満である必要があります。

画像

この例では、ローカルに保存されたファイル eagle.png を使用します。

import os
from openai import OpenAI
import base64

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)


# Base64 エンコード形式
def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")


base64_image = encode_image("eagle.png")

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus", # Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {"url": f"data:image/png;base64,{base64_image}"},
                },
                {"type": "text", "text": "What scene is depicted in the image?"},
            ],
        },
    ],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";
import { readFileSync } from 'fs';

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);

const encodeImage = (imagePath) => {
    const imageFile = readFileSync(imagePath);
    return imageFile.toString('base64');
};
const base64Image = encodeImage("eagle.png")

const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus",// Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages: [
        {
            "role": "user",
            "content": [{
                "type": "image_url",
                "image_url": { "url": `data:image/png;base64,${base64Image}` },
            },
            { "type": "text", "text": "What scene is depicted in the image?" }]
        }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}

音声

この例では、ローカルに保存されたファイル welcome.mp3 を使用します。

import os
from openai import OpenAI
import base64
import numpy as np
import soundfile as sf
import requests

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)


def encode_audio(audio_path):
    with open(audio_path, "rb") as audio_file:
        return base64.b64encode(audio_file.read()).decode("utf-8")


base64_audio = encode_audio("welcome.mp3")

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus", # Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_audio",
                    "input_audio": {
                        "data": f"data:;base64,{base64_audio}",
                        "format": "mp3",
                    },
                },
                {"type": "text", "text": "What is this audio about"},
            ],
        },
    ],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";
import { readFileSync } from 'fs';

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);

const encodeAudio = (audioPath) => {
    const audioFile = readFileSync(audioPath);
    return audioFile.toString('base64');
};
const base64Audio = encodeAudio("welcome.mp3")

const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus", // Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages: [
        {
            "role": "user",
            "content": [{
                "type": "input_audio",
                "input_audio": { "data": `data:;base64,${base64Audio}`, "format": "mp3" },
            },
            { "type": "text", "text": "What is this audio about" }]
        }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}

動画

動画ファイル

この例では、ローカルに保存されたファイル spring_mountain.mp4 を使用します。

import os
from openai import OpenAI
import base64
import numpy as np
import soundfile as sf

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

# Base64 エンコード形式
def encode_video(video_path):
    with open(video_path, "rb") as video_file:
        return base64.b64encode(video_file.read()).decode("utf-8")


base64_video = encode_video("spring_mountain.mp4")

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus", # Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "video_url",
                    "video_url": {"url": f"data:;base64,{base64_video}"},
                },
                {"type": "text", "text": "What is she singing?"},
            ],
        },
    ],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";
import { readFileSync } from 'fs';

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);

const encodeVideo = (videoPath) => {
    const videoFile = readFileSync(videoPath);
    return videoFile.toString('base64');
};
const base64Video = encodeVideo("spring_mountain.mp4")

const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus", // Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages: [
        {
            "role": "user",
            "content": [{
                "type": "video_url",
                "video_url": { "url": `data:;base64,${base64Video}` },
            },
            { "type": "text", "text": "What is she singing?" }]
        }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}

画像リスト

たとえば、ローカルに保存されたファイル football1.jpgfootball2.jpgfootball3.jpgfootball4.jpg を考えます。

import os
from openai import OpenAI
import base64
import numpy as np
import soundfile as sf

client = OpenAI(
    # シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
)


# Base64 エンコード形式
def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")


base64_image_1 = encode_image("football1.jpg")
base64_image_2 = encode_image("football2.jpg")
base64_image_3 = encode_image("football3.jpg")
base64_image_4 = encode_image("football4.jpg")

completion = client.chat.completions.create(
    model="qwen3.5-omni-plus", # Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "video",
                    "video": [
                        f"data:image/jpeg;base64,{base64_image_1}",
                        f"data:image/jpeg;base64,{base64_image_2}",
                        f"data:image/jpeg;base64,{base64_image_3}",
                        f"data:image/jpeg;base64,{base64_image_4}",
                    ],
                },
                {"type": "text", "text": "Describe the process shown in this video"},
            ],
        }
    ],
    # 出力モダリティを設定します。現在、["text","audio"] と ["text"] の 2 つのオプションがサポートされています
    modalities=["text", "audio"],
    audio={"voice": "Tina", "format": "wav"},
    # stream は True に設定する必要があります。そうしないと、エラーが発生します。
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in completion:
    if chunk.choices:
        print(chunk.choices[0].delta)
    else:
        print(chunk.usage)
import OpenAI from "openai";
import { readFileSync } from 'fs';

const openai = new OpenAI(
    {
        // シンガポールリージョンと北京リージョンでは API キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
        apiKey: process.env.DASHSCOPE_API_KEY,
        // 次の URL はシンガポールリージョン用です。呼び出し時に、WorkspaceId を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
        baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    }
);

const encodeImage = (imagePath) => {
    const imageFile = readFileSync(imagePath);
    return imageFile.toString('base64');
  };
const base64Image1 = encodeImage("football1.jpg")
const base64Image2 = encodeImage("football2.jpg")
const base64Image3 = encodeImage("football3.jpg")
const base64Image4 = encodeImage("football4.jpg")

const completion = await openai.chat.completions.create({
    model: "qwen3.5-omni-plus", // Qwen3-Omni-Flash の場合は、ノンシンキングモードで実行します。
    messages: [{
        role: "user",
        content: [
            {
                type: "video",
                video: [
                    `data:image/jpeg;base64,${base64Image1}`,
                    `data:image/jpeg;base64,${base64Image2}`,
                    `data:image/jpeg;base64,${base64Image3}`,
                    `data:image/jpeg;base64,${base64Image4}`
                ]
            },
            {
                type: "text",
                text: "Describe the process shown in this video"
            }
        ]
    }],
    stream: true,
    stream_options: {
        include_usage: true
    },
    modalities: ["text", "audio"],
    audio: { voice: "Tina", format: "wav" }
});

for await (const chunk of completion) {
    if (Array.isArray(chunk.choices) && chunk.choices.length > 0) {
        console.log(chunk.choices[0].delta);
    } else {
        console.log(chunk.usage);
    }
}

API リファレンス

入力および出力パラメーターについては、「OpenAI 互換チャット」をご参照ください。

課金とレート制限

課金ルール

Qwen-Omni は、モダリティ (音声、画像、動画) 全体で消費されたトークンに基づいて課金されます。課金の詳細はコンソールでご確認ください。

音声、画像、動画のトークン変換ルール

音声

  • Qwen3.5-Omni シリーズ:

    • 入力オーディオの数式: Total tokens = Audio duration (秒) * 7

    • 出力音声の数式: 合計トークン = 音声の持続時間 (秒) * 12.5

  • Qwen3-Omni-Flash では、入力と出力の両方のオーディオについて、合計トークン = オーディオの持続時間 (秒) * 12.5 となります。

  • Qwen-Omni-Turbo: 入力と出力の両方の音声について、 Total tokens = Audio duration (seconds) * 25 です。

音声の持続時間が 1 秒未満の場合は、1 秒として計算されます。

画像

  • Qwen3.5-Omni シリーズ および Qwen3-Omni-Flash は、 32x32 ピクセルあたり 1 トークン

  • Qwen-Omni-Turbo モデル: 28x28 ピクセルあたり 1 トークン

Qwen3.5-Omni シリーズでは、各イメージに最小 24 トークンが必要です。他のモデルでは、最小値は 4 トークンです。デフォルトの最大値は 1280 トークンです。Qwen3.5-Omni シリーズは vl_high_resolution_images パラメーターをサポートしており、最大値を 16384 トークンに増やすことができます (Qwen-Omni-Turbo および Qwen3-Omni-Flash はこのパラメーターをサポートしていません)。次のコードを使用して、単一イメージのトークン数を推定します。

import math
from PIL import Image  # pip install Pillow

# ============ モデル構成 (必要に応じて変更) ============

# 画像係数:Qwen3.5-Omni シリーズと Qwen3-Omni-Flash は 32、Qwen-Omni-Turbo は 28
IMAGE_FACTOR = 32

# 最小トークン数:Qwen3.5-Omni シリーズは 24、Qwen-Omni-Turbo と Qwen3-Omni-Flash は 4
MIN_TOKENS = 24

# 高解像度モード (Qwen3.5-Omni シリーズのみ、Qwen-Omni-Turbo または Qwen3-Omni-Flash は非対応)
# True  → 最大トークン数 = 16384
# False → 最大トークン数 = 1280 (デフォルト)
VL_HIGH_RESOLUTION_IMAGES = False

# ============ ピクセル範囲 (上記から自動計算) ============

MIN_PIXELS = MIN_TOKENS * IMAGE_FACTOR * IMAGE_FACTOR
MAX_PIXELS = (16384 if VL_HIGH_RESOLUTION_IMAGES else 1280) * IMAGE_FACTOR * IMAGE_FACTOR


def smart_resize(height, width, factor=IMAGE_FACTOR,
                 min_pixels=MIN_PIXELS, max_pixels=MAX_PIXELS):
    """画像のディメンションを係数の倍数に合わせ、[min_pixels, max_pixels] の範囲にスケーリングします。"""
    h_bar = max(factor, round(height / factor) * factor)
    w_bar = max(factor, round(width / factor) * factor)

    if h_bar * w_bar > max_pixels:
        beta = math.sqrt((height * width) / max_pixels)
        h_bar = math.floor(height / beta / factor) * factor
        w_bar = math.floor(width / beta / factor) * factor
    elif h_bar * w_bar < min_pixels:
        beta = math.sqrt(min_pixels / (height * width))
        h_bar = math.ceil(height * beta / factor) * factor
        w_bar = math.ceil(width * beta / factor) * factor

    return h_bar, w_bar


if __name__ == "__main__":
    image = Image.open("xxx/test.jpg")
    print(f"元のサイズ: {image.width}x{image.height}")

    resized_h, resized_w = smart_resize(image.height, image.width)
    token = int(resized_h * resized_w / (IMAGE_FACTOR * IMAGE_FACTOR)) + 2
    print(f"リサイズ後: {resized_w}x{resized_h}, トークン数: {token}")

動画

ビデオファイルのトークンは、video_tokensaudio_tokens に分けられます。

  • video_tokens

    計算は複雑です。次のコードをご参照ください:

    # pip install opencv-python
    import math
    import cv2
    
    # ============ モデル構成 (必要に応じて変更) ============
    
    # 画像係数:Qwen3.5-Omni シリーズと Qwen3-Omni-Flash は 32、Qwen-Omni-Turbo は 28
    IMAGE_FACTOR = 32
    
    FRAME_FACTOR = 2
    FPS = 2
    MAX_RATIO = 200
    
    # ビデオフレームあたりの最小ピクセル数
    VIDEO_MIN_PIXELS = 64 * IMAGE_FACTOR * IMAGE_FACTOR
    
    # ビデオフレームあたりの最大ピクセル数
    # Qwen3.5-Omni シリーズ: 640 * 32 * 32
    # Qwen3-Omni-Flash: 768 * 32 * 32
    # Qwen-Omni-Turbo: 768 * 28 * 28
    VIDEO_MAX_PIXELS = 640 * IMAGE_FACTOR * IMAGE_FACTOR
    
    # 抽出される最小フレーム数:Qwen3.5-Omni シリーズと Qwen3-Omni-Flash は 2、Qwen-Omni-Turbo は 4
    FPS_MIN_FRAMES = 2
    
    # 抽出される最大フレーム数:Qwen3.5-Omni シリーズは 2048、Qwen3-Omni-Flash は 128、Qwen-Omni-Turbo は 80
    FPS_MAX_FRAMES = 2048
    
    # ビデオ入力の合計最大ピクセル数
    # Qwen3.5-Omni シリーズ: 180224 * 32 * 32
    # Qwen3-Omni-Flash: 16384 * 32 * 32
    # Qwen-Omni-Turbo: 16384 * 28 * 28
    VIDEO_TOTAL_PIXELS = 180224 * IMAGE_FACTOR * IMAGE_FACTOR
    
    
    # ============ コア関数 ============
    
    def get_video_info(video_path):
        """ビデオの基本情報 (高さ、幅、総フレーム数、fps) を読み取ります。"""
        cap = cv2.VideoCapture(video_path)
        height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
        width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
        total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
        fps = cap.get(cv2.CAP_PROP_FPS)
        cap.release()
        return height, width, total_frames, fps
    
    
    def smart_nframes(total_frames, video_fps):
        """ビデオの持続時間と fps に基づいて抽出するフレーム数を計算します。"""
        min_frames = math.ceil(FPS_MIN_FRAMES / FRAME_FACTOR) * FRAME_FACTOR
        max_frames = min(FPS_MAX_FRAMES, total_frames) // FRAME_FACTOR * FRAME_FACTOR
    
        duration = total_frames / video_fps if video_fps else 0
        if duration - int(duration) > (1 / FPS):
            total_frames = math.ceil(duration * video_fps)
        else:
            total_frames = math.ceil(int(duration) * video_fps)
    
        nframes = total_frames / video_fps * FPS
        nframes = int(min(max(nframes, min_frames), max_frames, total_frames))
        if not (FRAME_FACTOR <= nframes <= total_frames):
            raise ValueError(f"nframes should in [{FRAME_FACTOR}, {total_frames}], got {nframes}")
        return nframes
    
    
    def smart_resize(height, width, nframes, factor=IMAGE_FACTOR):
        """ビデオフレームを適切なピクセル範囲にスケーリングし、係数の倍数に合わせます。"""
        max_pixels = max(
            min(VIDEO_MAX_PIXELS, VIDEO_TOTAL_PIXELS / nframes * FRAME_FACTOR),
            int(VIDEO_MIN_PIXELS * 1.05)
        )
        if max(height, width) / min(height, width) > MAX_RATIO:
            raise ValueError(f"aspect ratio exceeds {MAX_RATIO}")
    
        h_bar = max(factor, round(height / factor) * factor)
        w_bar = max(factor, round(width / factor) * factor)
    
        if h_bar * w_bar > max_pixels:
            beta = math.sqrt((height * width) / max_pixels)
            h_bar = math.floor(height / beta / factor) * factor
            w_bar = math.floor(width / beta / factor) * factor
        elif h_bar * w_bar < VIDEO_MIN_PIXELS:
            beta = math.sqrt(VIDEO_MIN_PIXELS / (height * width))
            h_bar = math.ceil(height * beta / factor) * factor
            w_bar = math.ceil(width * beta / factor) * factor
    
        return h_bar, w_bar
    
    
    # ============ トークンを計算 ============
    
    if __name__ == "__main__":
        video_path = "spring_mountain.mp4"
    
        height, width, total_frames, video_fps = get_video_info(video_path)
        print(f"ビデオ情報: {width}x{height}, {total_frames} フレーム, {video_fps:.1f} fps")
    
        nframes = smart_nframes(total_frames, video_fps)
        resized_h, resized_w = smart_resize(height, width, nframes)
    
        video_tokens = int(
            math.ceil(nframes / FPS) * resized_h / IMAGE_FACTOR * resized_w / IMAGE_FACTOR
        ) + 2
        print(f"抽出されたフレーム: {nframes}, リサイズ後: {resized_w}x{resized_h}, video_tokens: {video_tokens}")
  • audio_tokens

    • Qwen3.5-Omni シリーズ

      • 入力オーディオ: 合計トークン = オーディオの持続時間 (秒) * 7

      • 出力音声: 合計トークン = 音声の持続時間 (秒) * 12.5

    • Qwen3-Omni-Flash: 入力と出力の両方のオーディオにおいて、合計トークン数 = オーディオの持続時間 (秒) * 12.5

    • Qwen-Omni-Turbo:入力と出力の両方のオーディオでは、合計トークン = オーディオの持続時間 (秒) * 25

    持続時間が 1 秒未満の音声は 1 秒として計算されます。

無料クォータ

無料クォータの申請、クエリ、または使用については、「新規ユーザー向けの無料クォータ」をご参照ください。

レート制限

レート制限ルールとよくある質問については、「レート制限」をご参照ください。

エラーコード

モデルの呼び出しが失敗し、エラーメッセージが返された場合は、「エラーコード」で解決策をご参照ください。

音声リスト

Qwen-Omni モデルの音声リストについては、「音声リスト」をご参照ください。