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

Alibaba Cloud Model Studio:Anthropic 互換 Messages

最終更新日:Nov 18, 2026

3つの設定を変更するだけで、既存の Anthropic アプリケーションを Model Studio に移行できます。このトピックでは、リクエストとレスポンスのパラメーターについて、コード例を交えて説明します。

既存の Anthropic アプリケーションを Model Studio に移行するには、以下の設定を変更します。

  • api_key:Model Studio API キーに置き換えます。
  • base_url :以下に示す Model Studio のエンドポイントに置き換えます。
  • model:qwen3.7-plus などのサポートされているモデル名に置き換えます。

重要Alibaba Cloud Model Studio は、中国 (北京)、シンガポール、および中国 (香港) リージョン向けにワークスペース固有のドメインをリリースしました。新しい専用ドメインは、推論リクエストに対して優れたパフォーマンスと高い安定性を提供します。新しいドメインへの移行を推奨します。

  • 中国 (北京):https://dashscope.aliyuncs.com から https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
  • シンガポール:https://dashscope-intl.aliyuncs.com から https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
  • 中国 (香港):https://cn-hongkong.dashscope.aliyuncs.com から https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com

{WorkspaceId} はご利用のワークスペース ID で、Alibaba Cloud Model Studio コンソールの [ワークスペース詳細] ページで確認できます。既存のドメインも引き続き利用可能です。

シンガポール

SDK base_url:https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic

HTTP リクエスト URL:POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages

中国 (北京)

SDK base_url:https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic

HTTP リクエスト URL:POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1/messages

ドイツ (フランクフルト)

SDK base_url:https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/apps/anthropic

HTTP リクエスト URL:POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/apps/anthropic/v1/messages

米国 (バージニア)

SDK base_url:https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/apps/anthropic

HTTP リクエスト URL:POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/apps/anthropic/v1/messages

日本 (東京)

SDK base_url:https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/apps/anthropic

HTTP リクエスト URL:POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages

{WorkspaceId} を実際のワークスペース ID に置き換えてください。

認証:x-api-key ヘッダーまたは Authorization: Bearer ヘッダーのいずれかでModel Studio API キーを渡します。

リクエストボディ

model string (必須)

モデル名。サポートされているモデル:

サポートされているモデル

Qwen-Max: qwen4-max、qwen3.8-max, qwen3.7-max, qwen3.7-max-2026-05-20, qwen3.7-max-2026-06-08

Qwen-Plus: qwen3.7-plus, qwen3.7-plus-2026-05-26, qwen3.6-plus, qwen3.6-plus-2026-04-02, qwen3.5-plus, qwen3.5-plus-2026-04-20, qwen3.5-plus-2026-02-15, qwen-plus, qwen-plus-latest

Qwen-Flash: qwen3.8-flash, qwen3.7-flash, qwen3.7-flash-2026-07-15, qwen3.6-flash, qwen3.6-flash-2026-04-16, qwen3.5-flash, qwen3.5-flash-2026-02-23, qwen-flash, qwen-flash-2025-07-28

Qwen-Coder: qwen3-coder-flash

Qwen-VL: qwen3-vl-plus

Qwen オープンソースモデル: qwen3.6-27b, qwen3.5-397b-a17b, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b

サードパーティモデル

deepseek-v4-pro, deepseek-v4-flash-0731, kimi-k3.1-pro, kimi-k3, kimi-k2.7-code, kimi-k2.6, kimi-k2.5, glm-5.2, glm-5.1, glm-5, MiniMax-M2.5, deepseek-v4.1-flash-1017

max_tokens integer (必須)

  • qwen4-max、deepseek-v4-pro, deepseek-v4-flash-0731, qwen3.8-max, qwen3.8-flash: max_tokens は、応答コンテンツと Chain-of-Thought コンテンツの両方の最大合計トークン数です。モデルの出力がこの値を超えると、生成は早期に停止し、stop_reason は max_tokens になります。

    max_tokens は、応答コンテンツと思考プロセスの合計の長さを制限します。拡張思考が有効な場合、max_tokens > thinking.budget_tokens

  • glm-5.2: thinking.budget_tokens パラメーターが渡されない場合、max_tokens は応答コンテンツと Chain-of-Thought コンテンツの両方の最大合計トークン数です。モデルの出力がこの値を超えると、生成は早期に停止し、stop_reason は max_tokens になります。thinking.budget_tokens パラメーターが渡される場合、max_tokens は応答コンテンツの最大トークン数のみであり、思考トークンは thinking.budget_tokens によって個別にコントロールされます。

  • その他のモデル:応答コンテンツの最大トークン数。生成されたコンテンツがこの値を超えると、生成は早期に停止し、stop_reason は max_tokens になります。

    max_tokens は思考プロセスの長さを制限しません。拡張思考が有効な場合、思考トークンは thinking.budget_tokens によって個別にコントロールされます。

system string or array (任意)

モデルの動作を定義するシステムプロンプト。system はトップレベルパラメーターであり、messages 配列は system ロールを受け入れません。

文字列は、単一の type="text" ブロックに相当します。プロンプトキャッシュのブレークポイントをマークするには、配列を渡します。

プロパティ

type string (必須)

固定値:text。

text string (必須)

システムプロンプトのテキスト。

cache_control object (任意)

プロンプトキャッシュのブレークポイント。キャッシュヒット時、後続のリクエストはキャッシュ読み取りレートで請求されます。type のみを含み、ephemeral に固定されます。

プロパティ(Qwen4)

qwen4-max と のみ対応します。 Qwen4 のコンテンツブロックのキャッシュマーカーは ttl にも対応します。5m または 1h、既定値は 5m です。 明示的キャッシュ(Qwen4) を参照してください。

type string (必須)

ephemeral

ttl string (任意)

キャッシュ TTL。5m または 1h。既定値は 5m。

messages array (必須)

user と assistant のターンが交互に並んだメッセージ配列。

messages 配列要素

role string (必須)

メッセージのロール。有効な値:user、assistant。

content string or array (必須)

プレーンテキスト文字列または構造化されたコンテンツ配列。文字列は、type="text" の単一の content ブロックに相当します。

content 配列要素の型

thinking (qwen4-max)

type string

thinking

thinking string

signature string

思考の要約と暗号化署名。後続のリクエストでは thinking ブロック全体をそのまま返します。

Text

プロパティ

type string (必須)

固定値:text。

text string (必須)

テキストコンテンツ。

cache_control object (任意)

プロンプトキャッシュのブレークポイント。type のみを含み、ephemeral に固定されます。

プロパティ(Qwen4)

qwen4-max と のみ対応します。 Qwen4 のコンテンツブロックのキャッシュマーカーは ttl にも対応します。5m または 1h、既定値は 5m です。 明示的キャッシュ(Qwen4) を参照してください。

type string (必須)

ephemeral

ttl string (任意)

キャッシュ TTL。5m または 1h。既定値は 5m。

document (qwen4-max)

type string (必須)

固定値:document。

source object (必須)

イメージデータのソース。

プロパティ

type string (必須)

base64

media_type string

イメージの MIME タイプ (例:application/pdf)。type が base64 の場合に必須です。

data string

Base64 エンコードされたイメージデータ。type が base64 の場合に必須です。

Image (Vision モデルが必要)

プロパティ

type string (必須)

固定値:image。

source object (必須)

イメージデータのソース。

プロパティ

type string (必須)

有効な値:url (パブリックイメージ URL)、base64 (Base64 エンコード)。

url string

イメージのパブリック URL。type が url の場合に必須です。

media_type string

イメージの MIME タイプ (例:image/jpeg)。type が base64 の場合に必須です。

data string

Base64 エンコードされたイメージデータ。type が base64 の場合に必須です。

Video (Vision モデルが必要)

プロパティ

type string (必須)

固定値:video。

source object (必須)

ビデオデータのソース。

プロパティ

type string (必須)

有効な値:url (パブリックビデオ URL)、base64 (Base64 エンコード)。

url string

ビデオのパブリック URL。type が url の場合に必須です。

media_type string

ビデオの MIME タイプ (例:video/mp4)。type が base64 の場合に必須です。

data string

Base64 エンコードされたビデオデータ。type が base64 の場合に必須です。

PDF ドキュメント

qwen3.8-max、qwen3.8-flash、および qwen4 シリーズのモデルは、Anthropic 互換 Messages API で PDF ファイルの URL 入力に対応しています。messages[].content で type: "document" のコンテンツブロックを使用し、source.type を url に設定して、source.url に PDF ファイルの URL を指定します。

URL 入力では、type は必須で値は document です。source は必須のオブジェクトです。その中の type は必須の文字列で url に設定し、url は PDF ファイルの URL を指定する必須の文字列です。

この例ではシンガポールリージョンを使用します。{WorkspaceId} をワークスペース ID に置き換え、環境変数 DASHSCOPE_API_KEY に Model Studio の API キーを設定してください。

curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages' \
  --header 'Content-Type: application/json' \
  --header "x-api-key: $DASHSCOPE_API_KEY" \
  --data '{
    "model": "qwen3.8-max",
    "max_tokens": 1024,
    "messages": [{
      "role": "user",
      "content": [
        {
          "type": "document",
          "source": {
            "type": "url",
            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260616/qmycjl/1506.02640v5.pdf"
          }
        },
        {"type": "text", "text": "总结一下这个PDF文档的内容"}
      ]
    }]
  }'

PDF 理解

Tool use (assistant ロール、モデルによって返されるツール呼び出し命令)

プロパティ

type string (必須)

固定値:tool_use。

id string (必須)

ツール呼び出しの一意の識別子。後続の tool_result で結果を関連付けるために使用されます。

name string (必須)

呼び出されたツールの名前。

input object (必須)

ツール呼び出しの入力パラメーター。構造は、tools 内の対応するツールの input_schema によって決定されます。

cache_control object (任意)

プロンプトキャッシュのブレークポイント。type のみを含み、ephemeral に固定されます。ツール呼び出しのコンテンツはキャッシュプレフィックスに含まれます。

プロパティ(Qwen4)

qwen4-max と のみ対応します。 Qwen4 のコンテンツブロックのキャッシュマーカーは ttl にも対応します。5m または 1h、既定値は 5m です。 明示的キャッシュ(Qwen4) を参照してください。

type string (必須)

ephemeral

ttl string (任意)

キャッシュ TTL。5m または 1h。既定値は 5m。

Tool result (user ロール、モデルに返送されるツールの実行結果)

プロパティ

type string (必須)

固定値:tool_result。

tool_use_id string (必須)

tool_use ブロックの id に対応します。

content string (必須)

ツールによって返されたコンテンツ。

cache_control object (任意)

プロンプトキャッシュのブレークポイント。type のみを含み、ephemeral に固定されています。

プロパティ(Qwen4)

qwen4-max と のみ対応します。 Qwen4 のコンテンツブロックのキャッシュマーカーは ttl にも対応します。5m または 1h、既定値は 5m です。 明示的キャッシュ(Qwen4) を参照してください。

type string (必須)

ephemeral

ttl string (任意)

キャッシュ TTL。5m または 1h。既定値は 5m。

cache_control object (任意)

qwen4-max と のみ対応します。 リクエスト直下で自動キャッシュを有効にします。コンテンツブロックに手動のブレークポイントも設定できます。type は ephemeral 固定です。 非標準の最上位パラメーターは Python SDK の extra_body で渡します。Node.js SDK と curl では直接渡します。 明示的キャッシュ(Qwen4) を参照してください。

プロパティ

type string (必須)

ephemeral

ttl string (任意)

キャッシュ TTL。5m または 1h。既定値は 5m。

stream boolean (任意)

ストリーミングを有効にするかどうか。デフォルト値:false。

temperature number (任意)

生成されるテキストの多様性をコントロールします。有効値:[0, 2)。値が大きいほど、よりランダムな結果が生成されます。

注記この有効値は、公式の Anthropic の有効値 [0.0, 1.0] とは異なります。Anthropic から移行する際は、このパラメーターの値を確認してください。

top_p number (任意)

Nucleus サンプリングの確率しきい値。

temperature と top_p はどちらも生成されるテキストの多様性をコントロールできます。どちらか一方のみを設定することを推奨します。詳細については、「概要」をご参照ください。

top_k integer (任意)

サンプリング中の候補セットのサイズ。

stop_sequences array (任意)

生成を停止させるトリガーとなるテキストシーケンス。出力は一致したシーケンスの前に終了します。

注記一致後、応答の stop_reason は end_turn のままであり、応答には一致したシーケンスは含まれません。

thinking object (任意)

kimi-k3.1-pro はデフォルトで思考が有効です。

拡張思考の構成。有効にすると、モデルは応答する前に推論を行い、応答には thinking タイプのコンテンツブロックが含まれます。すべてのモデルが思考モードをサポートしているわけではありません。

このパラメーターが渡されない場合、思考が実行されるかどうかはモデルのデフォルトの動作で決まります:qwen4-max、qwen3.8-max、qwen3.8-flash、deepseek-v4 シリーズ、glm シリーズ、kimi-k3.1-pro はデフォルトで思考が有効、kimi-k2.6 と kimi-k2.5 はデフォルトで思考が無効、kimi-k2.7-code と MiniMax-M2.5 は思考モードのみサポート (無効化できません)。各モデルの思考モードのサポート状況とデフォルト設定については、ディープシンキングをご参照ください。

プロパティ

type string (必須)

有効な値:enabled (思考モードを有効にする)、disabled (思考モードを無効にする)。

budget_tokens integer (任意)

思考プロセスの最大トークン数。max_tokens との関係はモデルによって異なります。詳しくは max_tokens パラメーターの説明をご参照ください。予算が大きいほど、複雑な質問に対してより徹底的な分析が可能になります。type が enabled の場合に有効です。

display string (任意)

qwen4-max: "summarized". 思考の要約と暗号化.

デフォルトでは完全な思考を返します。有効にすると元の思考は平文では返されず、表示用の要約と履歴の復元用の完全な暗号文を返します。

tools array (任意)

関数呼び出しのためのツール定義。

tools 配列要素

name string (必須)

ツール名。

description string (任意)

ツール関数の説明。

input_schema object (必須)

ツール入力パラメーターの JSON スキーマ定義。

kimi-k3.1-pro (Alibaba Cloud Model Studio にデプロイ) は、北京、シンガポール、米国 (バージニア)、ドイツ (フランクフルト)、日本 (東京)、中国 (香港) で、web_search と web_fetch をサポートします。

deepseek-v4.1-flash-1017 は、ウェブ検索ツール web_search とウェブ取得ツール web_fetch をサポートします。Anthropic 互換リクエストの要件と例については、ウェブ抽出をご参照ください。

qwen4-max: web_search, web_fetch.

tools に名前が web_fetch のツールを追加し、同じリクエストに名前が web_search のツールも追加します。エンドポイントは https://{WorkspaceId}.{region}.maas.aliyuncs.com/apps/anthropic です。

web_fetch (qwen4-max)

type string

web_fetch_20250910

name string

web_fetch

max_uses integer

tool_choice object (任意)

ツール選択戦略:

  • {"type": "auto"}:モデルがツールを呼び出すかどうかを決定します (デフォルト)。
  • {"type": "any"}:モデルにいずれかのツールを強制的に呼び出させます。
  • {"type": "none"}:モデルがツールを呼び出すことを禁止します。
  • {"type": "tool", "name": "tool_name"}:モデルに指定されたツールを強制的に呼び出させます。

output_config object (任意)

プロパティ

effort string (任意)

qwen4-max

選択可能な値は low、high(デフォルト)、xhigh です。

medium は high に、max は xhigh にマッピングされます。

モデルの推論の強度をコントロールします。有効な値とデフォルト値はモデルによって異なります。デフォルト値:max。

kimi-k3.1-pro (Alibaba Cloud Model Studio にデプロイ) のデフォルトは max です。max (深い推論)、high (強化された推論)、medium (中程度の推論)、low (軽い推論) をサポートします。

  • qwen3.8-max/qwen3.8-flash:デフォルト値:xhigh

    有効な値:

    • xhigh:高強度の推論
    • medium:中程度の推論
    • low:軽い推論

    max、high は xhigh にマッピングされます。

以下は既存モデルの設定です。

有効な値:

  • high:高強度の推論
  • max:最大強度の推論

low と medium は high に、xhigh は max にマッピングされます。

サポートされているモデル:glm-5.2、deepseek-v4-pro。

format object (任意)

構造化出力の構成。有効にすると、モデルは JSON 文字列を返します。動作はモデルによって異なります。

  • 厳密な構造化出力:deepseek (deepseek-v4-flash-0731、deepseek-v4-pro-0813 を除く) および glm シリーズのモデルで利用可能です。モデルは提供された JSON スキーマに厳密に従い、同じフィールドタイプと階層を保証します。
  • 通常の構造化出力:他のすべてのモデルでは、スキーマフィールドの制約は強制されません。API は自動的にプレーンな JSON モード (出力が有効な JSON 文字列であることを保証するのみ) にフォールバックします。このフォールバックモードでは、リクエストは次の両方を満たす必要があります:(1) output_config パラメーターが明示的に提供されていること、(2) system または messages のコンテンツにキーワード「JSON」(大文字と小文字を区別しない) が含まれていること。キーワード「JSON」がない場合、API は 'messages' must contain the word 'json' in some form というエラーをスローします。

プロパティ

type string (必須)

固定値:json_schema。

schema object (必須)

標準の JSON スキーマ仕様に従う JSON スキーマオブジェクト。type (データの型)、properties (フィールド定義)、required (必須フィールド名の配列)、および additionalProperties ( false に設定する必要があります) を含める必要があります。

基本的な呼び出し

import anthropic
import os

client = anthropic.Anthropic(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

message = client.messages.create(
    model="qwen4-max",
    max_tokens=1024,
    system="You are a helpful assistant",
    messages=[
        {
            "role": "user",
            "content": "あなたは誰ですか?"
        }
    ],
    thinking={"type": "disabled"},
)

print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic({
  apiKey: process.env.DASHSCOPE_API_KEY,
  // {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
  baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
});

async function main() {
  const message = await anthropic.messages.create({
    model: "qwen4-max",
    max_tokens: 1024,
    system: "You are a helpful assistant",
    messages: [{
      role: "user",
      content: "あなたは誰ですか?"
    }],
    thinking: { type: "disabled" },
  });

  console.log(message.content[0].text);
}

main().catch(console.error);
curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $DASHSCOPE_API_KEY" \
  -d '{
    "model": "qwen4-max",
    "max_tokens": 1024,
    "system": "You are a helpful assistant",
    "messages": [
        {
            "role": "user",
            "content": "あなたは誰ですか?"
        }
    ],
    "thinking": {"type": "disabled"}
}'

ストリーミング

import anthropic
import os

client = anthropic.Anthropic(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

stream = client.messages.create(
    model="qwen4-max",
    max_tokens=1024,
    stream=True,
    messages=[
        {
            "role": "user",
            "content": "人工知能について簡単に紹介してください。"
        }
    ],
    thinking={"type": "disabled"},
)

for chunk in stream:
    if chunk.type == "content_block_delta":
        if hasattr(chunk.delta, 'text'):
            print(chunk.delta.text, end="", flush=True)
import Anthropic from "@anthropic-ai/sdk";

async function main() {
  const anthropic = new Anthropic({
    apiKey: process.env.DASHSCOPE_API_KEY,
    // {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
  });

  const stream = await anthropic.messages.create({
    model: "qwen4-max",
    max_tokens: 1024,
    stream: true,
    messages: [{
      role: "user",
      content: "人工知能について簡単に紹介してください。"
    }],
    thinking: { type: "disabled" },
  });

  for await (const chunk of stream) {
    if (chunk.type === "content_block_delta" && 'text' in chunk.delta) {
      process.stdout.write(chunk.delta.text);
    }
  }
}

main().catch(console.error);
curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $DASHSCOPE_API_KEY" \
  --no-buffer \
  -d '{
    "model": "qwen4-max",
    "max_tokens": 1024,
    "stream": true,
    "messages": [
        {
            "role": "user",
            "content": "人工知能について簡単に紹介してください。"
        }
    ],
    "thinking": {"type": "disabled"}
}'

拡張思考

import anthropic
import os

client = anthropic.Anthropic(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

stream = client.messages.create(
    model="qwen4-max",
    max_tokens=2048,
    stream=True,
    thinking={
        "type": "enabled",
        "budget_tokens": 1024
    },
    messages=[
        {
            "role": "user",
            "content": "量子コンピューティングの将来性について分析してください。"
        }
    ]
)

for chunk in stream:
    if chunk.type == "content_block_delta":
        if hasattr(chunk.delta, 'thinking'):
            print(chunk.delta.thinking, end="", flush=True)
        elif hasattr(chunk.delta, 'text'):
            print(chunk.delta.text, end="", flush=True)
import Anthropic from "@anthropic-ai/sdk";

async function main() {
  const anthropic = new Anthropic({
    apiKey: process.env.DASHSCOPE_API_KEY,
    // {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
  });

  const stream = await anthropic.messages.create({
    model: "qwen4-max",
    max_tokens: 2048,
    stream: true,
    thinking: { type: "enabled", budget_tokens: 1024 },
    messages: [{
      role: "user",
      content: "量子コンピューティングの将来性について分析してください。"
    }]
  });

  for await (const chunk of stream) {
    if (chunk.type === "content_block_delta") {
      if ('thinking' in chunk.delta) {
        process.stdout.write(chunk.delta.thinking);
      } else if ('text' in chunk.delta) {
        process.stdout.write(chunk.delta.text);
      }
    }
  }
}

main().catch(console.error);
curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $DASHSCOPE_API_KEY" \
  -d '{
    "model": "qwen4-max",
    "max_tokens": 2048,
    "stream": true,
    "thinking": {
        "type": "enabled",
        "budget_tokens": 1024
    },
    "messages": [
        {
            "role": "user",
            "content": "量子コンピューティングの将来性について分析してください。"
        }
    ]
}'

画像認識

import anthropic
import os

client = anthropic.Anthropic(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

stream = client.messages.create(
    model="qwen4-max",
    max_tokens=1024,
    stream=True,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image",
                    "source": {
                        "type": "url",
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250414/mqqmiy/animal_01.jpg",
                    },
                },
                {
                    "type": "text",
                    "text": "この画像の内容を説明してください。"
                },
            ],
        }
    ],
    thinking={"type": "disabled"},
)

for chunk in stream:
    if chunk.type == "content_block_delta":
        if hasattr(chunk.delta, 'text'):
            print(chunk.delta.text, end="", flush=True)
import Anthropic from "@anthropic-ai/sdk";

async function main() {
  const anthropic = new Anthropic({
    apiKey: process.env.DASHSCOPE_API_KEY,
    // {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
  });

  const stream = await anthropic.messages.create({
    model: "qwen4-max",
    max_tokens: 1024,
    stream: true,
    messages: [{
      role: "user",
      content: [
        {
          type: "image",
          source: {
            type: "url",
            url: "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250414/mqqmiy/animal_01.jpg",
          },
        },
        { type: "text", text: "この画像の内容を説明してください。" },
      ],
    }],
    thinking: { type: "disabled" },
  });

  for await (const chunk of stream) {
    if (chunk.type === "content_block_delta" && 'text' in chunk.delta) {
      process.stdout.write(chunk.delta.text);
    }
  }
}

main().catch(console.error);
curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $DASHSCOPE_API_KEY" \
  -d '{
    "model": "qwen4-max",
    "max_tokens": 1024,
    "stream": true,
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "image",
                    "source": {
                        "type": "url",
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250414/mqqmiy/animal_01.jpg"
                    }
                },
                {
                    "type": "text",
                    "text": "この画像の内容を説明してください。"
                }
            ]
        }
    ],
    "thinking": {"type": "disabled"}
}'

動画認識

import anthropic
import os

client = anthropic.Anthropic(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

stream = client.messages.create(
    model="qwen4-max",
    max_tokens=1024,
    stream=True,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "video",
                    "source": {
                        "type": "url",
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251208/zpupby/3e81ef38-98f0-4d55-bbb6-259334ca18d0.mp4",
                    },
                },
                {
                    "type": "text",
                    "text": "この動画の内容を説明してください。"
                },
            ],
        }
    ],
    thinking={"type": "disabled"},
)

for chunk in stream:
    if chunk.type == "content_block_delta":
        if hasattr(chunk.delta, 'text'):
            print(chunk.delta.text, end="", flush=True)
import Anthropic from "@anthropic-ai/sdk";

async function main() {
  const anthropic = new Anthropic({
    apiKey: process.env.DASHSCOPE_API_KEY,
    // {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
  });

  const stream = await anthropic.messages.create({
    model: "qwen4-max",
    max_tokens: 1024,
    stream: true,
    messages: [{
      role: "user",
      content: [
        {
          type: "video",
          source: {
            type: "url",
            url: "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251208/zpupby/3e81ef38-98f0-4d55-bbb6-259334ca18d0.mp4",
          },
        },
        { type: "text", text: "この動画の内容を説明してください。" },
      ],
    }],
    thinking: { type: "disabled" },
  });

  for await (const chunk of stream) {
    if (chunk.type === "content_block_delta" && 'text' in chunk.delta) {
      process.stdout.write(chunk.delta.text);
    }
  }
}

main().catch(console.error);
curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $DASHSCOPE_API_KEY" \
  -d '{
    "model": "qwen4-max",
    "max_tokens": 1024,
    "stream": true,
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "video",
                    "source": {
                        "type": "url",
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251208/zpupby/3e81ef38-98f0-4d55-bbb6-259334ca18d0.mp4"
                    }
                },
                {
                    "type": "text",
                    "text": "この動画の内容を説明してください。"
                }
            ]
        }
    ],
    "thinking": {"type": "disabled"}
}'

関数呼び出し

import anthropic
import os

client = anthropic.Anthropic(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

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

message = client.messages.create(
    model="qwen4-max",
    max_tokens=1024,
    tools=tools,
    messages=[
        {
            "role": "user",
            "content": "今日の杭州の天気はどうですか?"
        }
    ]
)

print(message.content)
import Anthropic from "@anthropic-ai/sdk";

async function main() {
  const anthropic = new Anthropic({
    apiKey: process.env.DASHSCOPE_API_KEY,
    // {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
  });

  const message = await anthropic.messages.create({
    model: "qwen4-max",
    max_tokens: 1024,
    tools: [
      {
        name: "get_weather",
        description: "指定された都市の天気情報を取得します",
        input_schema: {
          type: "object",
          properties: {
            city: { type: "string", description: "都市名" }
          },
          required: ["city"],
        },
      },
    ],
    messages: [{
      role: "user",
      content: "今日の杭州の天気はどうですか?"
    }],
  });

  console.log(JSON.stringify(message.content, null, 2));
}

main().catch(console.error);
curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $DASHSCOPE_API_KEY" \
  -d '{
    "model": "qwen4-max",
    "max_tokens": 1024,
    "tools": [
        {
            "name": "get_weather",
            "description": "指定された都市の天気情報を取得します",
            "input_schema": {
                "type": "object",
                "properties": {
                    "city": {
                        "type": "string",
                        "description": "都市名"
                    }
                },
                "required": ["city"]
            }
        }
    ],
    "messages": [
        {
            "role": "user",
            "content": "今日の杭州の天気はどうですか?"
        }
    ]
}'

プロンプトキャッシュ

import anthropic
import os

client = anthropic.Anthropic(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

# コードリポジトリのコンテンツをシミュレートします。キャッシュ可能な最小長 (1024 トークン) に達する必要があります
long_text_content = "<Your Code Here>" * 400

def get_completion(user_input):
    response = client.messages.create(
        # プロンプトキャッシュをサポートするモデルを選択します
        model="qwen4-max",
        max_tokens=1024,
        system=[
            {
                "type": "text",
                "text": long_text_content,
                # テキストブロックに cache_control を追加して、キャッシュのブレークポイントをマークします。messages 配列のコンテンツブロックにも配置できます
                "cache_control": {"type": "ephemeral"},
            }
        ],
        messages=[
            {"role": "user", "content": user_input},
        ],
    )
    return response

# 最初のリクエスト:キャッシュを作成
first = get_completion("このコードは何をしますか?")
print(f"Cache creation tokens: {first.usage.cache_creation_input_tokens}")
print(f"Cache read tokens: {first.usage.cache_read_input_tokens}")
print("=" * 20)
# 2番目のリクエスト:同じ長いコンテンツ、異なる質問 -> キャッシュヒット
second = get_completion("このコードはどのように最適化できますか?")
print(f"Cache creation tokens: {second.usage.cache_creation_input_tokens}")
print(f"Cache read tokens: {second.usage.cache_read_input_tokens}")
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.DASHSCOPE_API_KEY,
  // {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
  baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
});

// コードリポジトリのコンテンツをシミュレートします。キャッシュ可能な最小長 (1024 トークン) に達する必要があります
const longTextContent = "<Your Code Here>".repeat(400);

async function getCompletion(userInput) {
  return client.messages.create({
    // プロンプトキャッシュをサポートするモデルを選択します
    model: "qwen4-max",
    max_tokens: 1024,
    system: [
      {
        type: "text",
        text: longTextContent,
        // テキストブロックに cache_control を追加して、キャッシュのブレークポイントをマークします。messages 配列のコンテンツブロックにも配置できます
        cache_control: { type: "ephemeral" },
      },
    ],
    messages: [{ role: "user", content: userInput }],
  });
}

// 最初のリクエスト:キャッシュを作成
const first = await getCompletion("このコードは何をしますか?");
console.log(`Cache creation tokens: ${first.usage.cache_creation_input_tokens}`);
console.log(`Cache read tokens: ${first.usage.cache_read_input_tokens}`);
console.log("=".repeat(20));
// 2番目のリクエスト:同じ長いコンテンツ、異なる質問 -> キャッシュヒット
const second = await getCompletion("このコードはどのように最適化できますか?");
console.log(`Cache creation tokens: ${second.usage.cache_creation_input_tokens}`);
console.log(`Cache read tokens: ${second.usage.cache_read_input_tokens}`);
curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $DASHSCOPE_API_KEY" \
  -d '{
    "model": "qwen4-max",
    "max_tokens": 1024,
    "system": [
      {
        "type": "text",
        "text": "<ここに少なくとも 1024 トークンのキャッシュ可能なコンテンツを配置します>",
        "cache_control": {"type": "ephemeral"}
      }
    ],
    "messages": [
      {"role": "user", "content": "このコードは何をしますか?"}
    ]
}'

構造化出力

import anthropic
import os

client = anthropic.Anthropic(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

message = client.messages.create(
    model="deepseek-v4-pro",
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": "次のメールから重要な情報を抽出してください:田中一郎 (tanaka@example.com) は Enterprise プランに興味があり、来週火曜日の午後2時にデモを希望しています。"
        }
    ],
    extra_body={
        "output_config": {
            "format": {
                "type": "json_schema",
                "schema": {
                    "type": "object",
                    "properties": {
                        "name": {"type": "string"},
                        "email": {"type": "string"},
                        "plan_interest": {"type": "string"},
                        "demo_requested": {"type": "boolean"}
                    },
                    "required": ["name", "email", "plan_interest", "demo_requested"],
                    "additionalProperties": False
                }
            }
        }
    },
)

# deepseek-v4-pro は thinking ブロックを返すため、text コンテンツブロックを見つけます
text_block = next(block for block in message.content if block.type == "text")
print(text_block.text)
import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic({
  apiKey: process.env.DASHSCOPE_API_KEY,
  // {WorkspaceId} を実際のワークスペース ID に置き換えてください。URL はリージョンによって異なります。
  baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
});

async function main() {
  // output_config は Model Studio プラットフォームの拡張パラメーターであり、ボディ経由で渡します
  const message = await (anthropic.messages.create as Function)({
    model: "deepseek-v4-pro",
    max_tokens: 1024,
    messages: [{
      role: "user",
      content: "次のメールから重要な情報を抽出してください:田中一郎 (tanaka@example.com) は Enterprise プランに興味があり、来週火曜日の午後2時にデモを希望しています。"
    }],
    output_config: {
      format: {
        type: "json_schema",
        schema: {
          type: "object",
          properties: {
            name: { type: "string" },
            email: { type: "string" },
            plan_interest: { type: "string" },
            demo_requested: { type: "boolean" }
          },
          required: ["name", "email", "plan_interest", "demo_requested"],
          additionalProperties: false
        }
      }
    }
  });

  // deepseek-v4-pro は thinking ブロックを返すため、text コンテンツブロックを見つけます
  const textBlock = message.content.find(
    (block: { type: string }) => block.type === "text"
  );
  console.log(textBlock?.text);
}

main().catch(console.error);
curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $DASHSCOPE_API_KEY" \
  -d '{
    "model": "deepseek-v4-pro",
    "max_tokens": 1024,
    "messages": [
        {
            "role": "user",
            "content": "次のメールから重要な情報を抽出してください:田中一郎 (tanaka@example.com) は Enterprise プランに興味があり、来週火曜日の午後2時にデモを希望しています。"
        }
    ],
    "output_config": {
        "format": {
            "type": "json_schema",
            "schema": {
                "type": "object",
                "properties": {
                    "name": {"type": "string"},
                    "email": {"type": "string"},
                    "plan_interest": {"type": "string"},
                    "demo_requested": {"type": "boolean"}
                },
                "required": ["name", "email", "plan_interest", "demo_requested"],
                "additionalProperties": false
            }
        }
    }
}'

非ストリーミング応答

id string

一意のメッセージ識別子。

type string

固定値:message。

role string

固定値:assistant。

model string

生成に使用されたモデル。

content array

コンテンツ配列。

content 配列要素の型

Text

プロパティ

type string

固定値:text。

text string

モデルによって生成されたテキスト応答。

Thinking (拡張思考が有効な場合に返されます)

プロパティ

type string

固定値:thinking。

thinking string

最終応答前のモデルの推論。

signature string

qwen4-max, thinking.display="summarized": Anthropic Messages の thinking block は thinking 要約と signature 暗号文を含みます。thinking_delta、完全な signature_delta の順に返され、ブロック終了後に本文やツール呼び出しを返します。暗号化の失敗や思考がない場合、signature は空文字列になることがあります。

thinking.display != "summarized": 現在は空の文字列に固定されています。

Tool use (関数呼び出しシナリオ)

プロパティ

type string

固定値:tool_use。

id string

一意のツール呼び出し識別子。tool_result と一致させるために使用されます。

name string

呼び出されたツールの名前。

input object

ツール呼び出しの入力パラメーター。

ウェブ取得結果(web_fetch_tool_result)

ウェブ取得結果

フィールド型説明
typestringweb_fetch_tool_result
tool_use_idstring対応する server_tool_use.id。
contentobject取得結果。
content.typestringweb_fetch_result
content.urlstringウェブページの URL。
content.retrieved_atstring取得日時。
content.contentobjectウェブページのドキュメント。
content.content.typestringdocument
content.content.titlestringウェブページのタイトル。
content.content.sourceobjectドキュメントの内容。
content.content.source.typestringtext
content.content.source.media_typestringtext/plain
content.content.source.datastringドキュメントの内容。
callerobject呼び出し元の情報。
caller.typestringdirect

stop_reason string

生成が停止した理由。有効な値:end_turn (正常終了)、max_tokens (トークン制限に到達)、tool_use (ツール呼び出し)。

stop_sequence string

常に null です。

usage object

トークン使用量の統計。

注記ストリーミング呼び出しでは、message_start イベントの usage フィールドには input_tokens と output_tokens のみが含まれます。4つのフィールドすべては message_delta イベントで返されます。

プロパティ

input_tokens integer

入力トークン。

output_tokens integer

出力トークン。

cache_creation_input_tokens integer

キャッシュ作成で消費されたトークン。

cache_read_input_tokens integer

キャッシュ読み取りで消費されたトークン。

server_tool_use object

server_tool_use

web_search_requests integer

Web 検索リクエスト数。

web_fetch_requests integer

Web ページの取得リクエスト数。

プロパティ(Qwen4)

明示的キャッシュ(Qwen4) を参照してください。

input_tokens integer

キャッシュの読み取りと作成のどちらにも該当しない入力トークン数。全入力はこの値とキャッシュ読み取り、作成トークン数の合計です。

output_tokens integer

出力トークン。

cache_creation_input_tokens integer

キャッシュ作成で消費されたトークン。

cache_read_input_tokens integer

キャッシュ読み取りで消費されたトークン。

server_tool_use object

server_tool_use

web_search_requests integer

Web 検索リクエスト数。

web_fetch_requests integer

Web ページの取得リクエスト数。

cache_creation object

TTL 別のキャッシュ作成詳細。2 つの TTL のトークン数の合計は、このリクエストのキャッシュ作成トークン数です。

プロパティ

ephemeral_5m_input_tokens integer

5 分間のキャッシュ作成トークン数。

ephemeral_1h_input_tokens integer

1 時間のキャッシュ作成トークン数。

prompt_tokens_details object

キャッシュ読み取り詳細。cached_tokens は cache_read_input_tokens と同じです。重複して加算しないでください。

プロパティ

cached_tokens integer

キャッシュから読み取った入力トークン数。

応答例

以下は応答フィールドを説明するための qwen3.8-max の応答例です。

{
  "id": "msg_e2898f19-fc0e-4cb3-bd9b-5b7dc4ea3bc9",
  "type": "message",
  "role": "assistant",
  "model": "qwen3.8-max",
  "content": [
    {
      "type": "thinking",
      "thinking": "この問題を分析してみましょう...",
      "signature": ""
    },
    {
      "type": "text",
      "text": "こんにちは!私は Qwen です..."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 22,
    "output_tokens": 223,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0
  }
}

ストリーミング応答

message_start

最初のストリームイベントで、メッセージの開始を示します。

プロパティ

type string

固定値:message_start。

message object

初期メッセージオブジェクト。content は空の配列で、usage には input_tokens と output_tokens のみが含まれます。

content_block_start

コンテンツブロックの開始を示します。

プロパティ

type string

固定値:content_block_start。

index integer

content 配列内の位置に対応する0から始まるインデックス。

content_block object

コンテンツブロックの初期オブジェクト。type の値は text、thinking、または tool_use, server_tool_use, web_search_tool_result, web_fetch_tool_result です。tool_use タイプの場合、このイベントでは input フィールドは空のオブジェクトであり、完全な入力パラメーターは後続の content_block_delta デルタから組み立てられます。

content_block_delta

コンテンツブロックの増分更新。ブロックごとに複数のデルタが送信されます。

プロパティ

type string

固定値:content_block_delta。

index integer

関連するコンテンツブロックのインデックス。

delta object

デルタオブジェクト。type の値:

  • text_delta:テキストデルタ。text フィールドを含みます。
  • thinking_delta:思考デルタ。thinking フィールドを含みます。
  • signature_delta (signature): qwen4-max, thinking.display="summarized": Anthropic Messages の thinking block は thinking 要約と signature 暗号文を含みます。thinking_delta、完全な signature_delta の順に返され、ブロック終了後に本文やツール呼び出しを返します。暗号化の失敗や思考がない場合、signature は空文字列になることがあります。 thinking.display != "summarized": signature="".
  • input_json_delta:ツール呼び出し入力パラメーターデルタ。partial_json フィールドを含みます。
content_block_stop

コンテンツブロックの終了を示します。

プロパティ

type string

固定値:content_block_stop。

index integer

終了したコンテンツブロックのインデックス。

message_delta

すべてのコンテンツブロックが終了した後に送信されます。停止理由と最終的なトークン使用量が含まれます。

プロパティ

type string

固定値:message_delta。

delta object

stop_reason と stop_sequence を含みます。有効な値については、上記の非ストリーミング応答の表をご参照ください。

usage object

input_tokens、output_tokens、cache_creation_input_tokens、cache_read_input_tokens を含む、完全なトークン使用量の統計。

message_stop

最後のイベントで、メッセージの終了を示します。

プロパティ

type string

固定値:message_stop。

さらに、ストリーミング応答は定期的に ping イベント ({"type":"ping"}) を送信して接続を維持します。クライアントはこれらを無視できます。

ストリーミング応答の例

以下は応答フィールドを説明するための qwen3.8-max の応答例です。

{"type":"message_start","message":{"id":"msg_xxx","type":"message","role":"assistant","model":"qwen3.8-max","content":[],"usage":{"input_tokens":15,"output_tokens":0}}}
{"type":"content_block_start","index":0,"content_block":{"type":"thinking","thinking":"","signature":""}}
{"type":"content_block_delta","index":0,"delta":{"type":"thinking_delta","thinking":"思考プロセスは次のとおりです:\n\n1. **ユーザー入力の分析:**\n   - **トピック:** 人工知能 (AI)\n   - **リクエスト:** 人工知能について簡単に紹介してください。"}}
{"type":"content_block_delta","index":0,"delta":{"type":"signature_delta","signature":""}}
{"type":"content_block_stop","index":0}
{"type":"content_block_start","index":1,"content_block":{"type":"text","text":""}}
{"type":"content_block_delta","index":1,"delta":{"type":"text_delta","text":"人工知能 (AI) は、コンピューターサイエンスの重要なブランチです..."}}
{"type":"content_block_stop","index":1}
{"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"input_tokens":15,"output_tokens":1078,"cache_creation_input_tokens":0,"cache_read_input_tokens":0}}
{"type":"message_stop"}

よくある質問

Claude Desktop または Claude Code を設定した後、接続テストがModel discovery — Gateway /v1/models returned HTTP 404で失敗するか、リクエスト URL に/v1/v1/modelsが含まれます。どうすれば修正できますか?

Claude Desktop や Claude Code などのクライアントのモデル検出機能は、設定されたベース URL に自動的に /v1/models を追加します。次の2点を確認してください。

  • ベース URL の末尾を/v1/にしないでください:末尾は /apps/anthropic である必要があります (たとえば、中国 (北京) の場合は https://dashscope.aliyuncs.com/apps/anthropic を使用します。他のリージョンについては、上記のエンドポイント情報をご参照ください)。誤って .../apps/anthropic/v1/ と入力すると、クライアントは /v1/models を追加し、重複したパス /v1/v1/models が生成され、HTTP 404 が返されます。したがって、404 エラーが発生した場合は、まず実際のリクエスト URL に重複した /v1/v1/ が含まれていないか確認してください。含まれている場合は、ベース URL から末尾の /v1/ を削除してください。
  • モデルを手動で追加して検出をスキップする:Model Studio の Anthropic 互換エンドポイントは Messages API (/v1/messages) のみを提供し、モデルリストエンドポイント (/v1/models) は提供しないため、モデル検出リクエストも 404 を返します。クライアントの [Models] でモデル (例:qwen3.7-plus) を手動で追加して、自動検出をスキップしてください。