Skip to content

Anthropic-compatible Messages API

Reference, synced 2026-06-13.

flowchart TD
  n0["Models"]
  n1["Overview"]
  n2["Products"]
  n3["Solutions"]
  n4["Pricing"]
  n5["Resources"]
  n6["Partners"]
  n7["Support"]
  n8["Language"]
  n0 --> n1
  n1 --> n2
  n2 --> n3
  n3 --> n4
  n4 --> n5
  n5 --> n6
  n6 --> n7
  n7 --> n8

Free access Accelerate Delivery with Fixed-Cost Agentic CodingWatch how it works

Models

Empowering AI innovation for both enterprises and developers with Alibaba Cloud’s best-in-class Qwen models, AI-native apps, and AI solutions.

Alibaba Cloud Model Studio \ Enterprise-grade large model service and application development platform.

Try Visual Model \ Supports image understanding, image generation, and video generation.

Models

HappyHorse-1.0-T2V \ Cinematic creative generation, ultimate dynamic details Qwen3-VL-Plus \ Native VL, spatial reasoning, 1M-context video analysis Wan2.7-VideoEdit \ Supports both localized and global editing with prompt

Qwen3.6-Plus \ Native multimodal, 1M context, agentic coding Wan2.7-Image-Pro \ Interactive editing, long-text rendering, precise prompt following Qwen-Plus \ Balanced intelligence, efficient inference, production-ready performance

Qwen-Image-2.0 \ Professional infographics, exquisite photorealism Z-Image-Turbo \ Ultra-fast image generation, high throughput, cost-optimized inference Qwen3-Coder-Next \ Multi-turn tool interactions, future-ready development support

Wan2.7-T2V \ High-fidelity T2V, 15s duration, advanced camera control Wan2.7-I2V \ Cinematic I2V with emotional depth and visceral impact Wan2.7-R2V \ Up to 5 mixed image/video inputs and audio timbre cloning

GenAI Application

Qoder \ Intelligent coding assistant, available for enterprise-dedicated deployment. Qoder CN \ AI-powered coding assistant that boosts developer productivity with intelligent code completion, AI chat, multi-file editing, and task automation.

AI Service

Model Experience \ Experience full-scale, multimodal model capabilities online. Platform for AI \ An AI-native algorithm engineering platform for end-to-end modeling, training, and inference service deployment. Fine-tune Video Generation Model \ Customize Wan’s text-to-video capabilities through model fine-tuning to meet your unique requirements.

AI Use Case

AI Savings Plan Hot \ Save up to 47% on AI costs. Limited-time offer tailored to your usage. AI Video Creation \ Elevate your professional video production with Wan 2.6.

AI Token Plan \ One plan. Multiple models. Big Savings with a Fixed Subscription. AI Image Creation \ All-in-one creative suite for copywriting, image generation, and poster design.

Overview

As a global full-stack AI leader, Alibaba Cloud aims to make computing accessible to everyone and help worldwide customers accelerate innovation.

Why Alibaba Cloud

About Alibaba Cloud \ AI Powered Cloud Technology Our Global Network \ Explore our global presence and deployment regions around the world Our Global Offices \ With offices in 4 continents, we're always close to where it matters.

Asia Accelerator \ Accelerate Success in Asia with Alibaba Cloud Go Global \ Benefits of our Global Alliance Trust Center \ Empowering enterprises with a secure, compliant, and globally trusted cloud infrastructure

Customers and Insights

Olympic Games \ Alibaba Cloud Powers Olympic Games with AI-powered cloud technology Case Studies \ Learn how customers are scaling their businesses on Alibaba Cloud Analyst Reports \ Learn what the top industry analyst firms are saying about Alibaba Cloud

What's New

Events and Webinars \ Quick access to upcoming and on-demand events Product Updates \ Stay informed of the latest innovations Press Room \ Latest news and media releases

Products

Featured ProductsAI & Machine Learning Computing Container Storage Networking & CDN Security Middleware Database Analytics ComputingMedia ServicesEnterprise Services & Cloud CommunicationDomain Names and WebsitesEnd User ComputingServerlessDeveloper ToolsMigration & O&M ManagementApsara Stack

Alibaba Cloud Model Studio \ Supercharge your AI journey effortlessly with industry-leading GenAI models ApsaraDB RDS \ Store and manage your business data, with automated monitoring and backups Certificate Management Service (Original SSL Certificate) \ Create a safe and secure connection between your website and users

Elastic Compute Service (ECS) \ Host websites anywhere and scale enterprise workloads Container Service for Kubernetes (ACK) \ Run and scale containerized applications on managed Kubernetes infrastructure Object Storage Service (OSS) \ Store large amounts of data in the cloud and access it anywhere, anytime

Simple Application Server (SAS) \ All-in-one services for fast deployment Elastic IP Address (EIP) \ Manage your public IPs independently to improve internet network quality Domain Names and Website \ Get the perfect domain name to suit your every need

Solutions

Solutions by Industry Technical Solutions AI WebsitesNetworking Security and ComplianceData and AnalyticsEnterprise Service and ApplicationCloud MigrationCloud NativeHybrid CloudSMB solutions

Financial Services \ Innovate faster with Alibaba Cloud Games \ Grow your game rapidly with high global availability

New Retail \ Alibaba Cloud enables digital retail transformation to fuel growth and realize an omnichannel customer experience throughout the consumer journey. Media and Entertainment \ Ready your content for today's media market with a digitalized media journey

Supply Chain \ Power your supply chain with intelligent, efficient, and reliable solutions Sports \ Digitizing the sports industry with intelligent tech

Sustainability \ Achieve a sustainable future with low-carbon and energy-efficient technologies

Pricing

Flexible options like pay-as-you-go and clear billing rules to meet diverse business needs.

Overview & Tools

Pricing Calculator \ Get an instant pricing estimate based on your usage and needs Free Trial \ Try our 80+ cloud products for free.

Pricing Options \ Get the most out of Alibaba Cloud with flexible pricing

Optimize your cost

Migrate & Save \ Superior Performance At Lower Pricing. Save up to 50%. Promotion Center \ Unlock the latest Alibaba Cloud offers & promos

Resources

Official documentation, extensive tools, training resources, and a community to grow and innovate in the cloud.

Technical Resources

Documentation \ Product guides and FAQs Architecture Center \ Design reliable, secure, and efficient cloud architecture. Intelligent Solution Explorer \ Find the right solution for you, powered by AI

Blog \ Latest cloud insights and developer trends Whitepapers \ Research that explores the how and why behind our technology

Training&Certification

Alibaba Cloud Academy \ Build cloud skills and earn certifications with expert-led training.

Developer Hub

Alibaba Cloud Project Hub \ Explore real-world projects built by developers using our platform. Our Developer MVPs \ Celebrating the developers who lead, build, and inspire our community

Partners

Partner-first strategy offering collaborative product, sales, and service models, plus high-quality partner solutions that complement Alibaba Cloud’s capabilities.

Marketplace

AI Alliance for ISVs \ Partner with us to build and grow AI solutions together ISV Benefits \ Unlock resources, market access, and go-to-market support as an ISV partner

Alibaba Cloud Marketplace \ Explore ready-to-deploy solutions from our partners and ISVs

Find a Partner

Partner Hub \ Find your ideal partner in no time

Become a Partner

Partner Network \ A partner portal for Alibaba Cloud Channel, Technology, MSP partner and other partner programs

Support

Full-lifecycle support and expert services, from cloud advisory and migration to operations.

Support & Professional Services

Professional Services \ Expert-led services to design, migrate, and optimize your cloud journey Support Plans \ Flexible support for every stage — from startup to enterprise

Partner Support Program \ Priority technical support for partners, with dedicated managers and faster issue resolution

Contact us

Connect With Us \

Talk to a sales expert and get a custom quote for your business

Language

  • English
  • 简体中文
  • 繁體中文
  • 日本語
  • Bahasa Indonesia

Locale

Visit aliyun.com

Documentation

Alibaba Cloud Model Studio

User Guide (Models) User Guide (Application) API Reference (Models) API Reference (Application)

Search for Help Content

Getting Started

The Beginner's Guide

Well-Architected Framework

AI & Machine Learning

Platform For AI

Alibaba Cloud Model Studio

DashVector

Artificial Intelligence Recommendation

OpenSearch

Image Search

Machine Translation

Intelligent Speech Interaction

Optimization Solver

Intelligent Computing LINGJUN

Computing

Elastic Compute Service

Elastic GPU Service

Elastic Container Instance

Dedicated Host

Compute Nest

Simple Application Server

Cloud Box

Auto Scaling

Elastic High Performance Computing

Batch Compute (Deprecated)

Function Compute

Serverless App Engine

ENS

Elastic Desktop Service

App Streaming

WUYING Terminal

Cloud Phone

Edge Network Acceleration

Alibaba Cloud Linux

AgentBay

Container

Container Service for Kubernetes

Container Compute Service

Container Registry

Storage

Object Storage Service

Cloud Parallel File Storage

File Storage NAS

Tablestore

Storage Capacity Unit

Simple Log Service

Cloud Backup

Intelligent Media Management

Drive and Photo Service

Data Transport

Cloud Storage Gateway

Data Online Migration

Hybrid Cloud Storage Array

Storage Services Overview

Backup and Disaster Recovery Center

Networking and CDN

Server Load Balancer

Elastic IP Address

Internet Shared Bandwidth

Data Transfer Plan

Virtual Private Cloud

NAT Gateway

PrivateLink

Alibaba Cloud DNS PrivateZone

Network Intelligence Service

Cloud Data Transfer

IPv6 Gateway

Anycast Elastic IP Address

Cloud Enterprise Network

Global Accelerator

VPN Gateway

Smart Access Gateway

Express Connect

CDN

Edge Security Acceleration

Cloud Network Well-architected Design Guidelines

Security

Anti-DDoS

Web Application Firewall

Cloud Firewall

Security Center

Bastionhost

Secure Access Service Edge

Certificate Management Service

Key Management Service

Data Security Center

Identity as a Service

Fraud Detection

AI Guardrails

Captcha

Blockchain as a Service

ID Verification

Managed Security Service

Middleware

Enterprise Distributed Application Service

Microservices Engine

Alibaba Cloud Service Mesh

SchedulerX

ApsaraMQ for RocketMQ

ApsaraMQ for Kafka

ApsaraMQ for RabbitMQ

ApsaraMQ for MQTT

Simple Message Queue (formerly MNS)

CloudFlow

EventBridge

Application Real-Time Monitoring Service

Managed Service for Prometheus

Managed Service for Grafana

Managed Service for OpenTelemetry

Performance Testing

STAROps

Databases

ApsaraDB Console

PolarDB

ApsaraDB RDS

ApsaraDB for OceanBase (Deprecated)

Tair (Redis® OSS-Compatible)

Lindorm

Time Series Database

ApsaraDB for MongoDB

ApsaraDB for HBase

ApsaraDB for Memcache

ApsaraDB for MyBase

AnalyticDB

ApsaraDB for ClickHouse

ApsaraDB for SelectDB

Data Transmission Service

Database Autonomy Service

Data Management

Database Gateway - Deprecated

ApsaraDB for Cassandra - Deprecated

Analytics Computing

MaxCompute

Hologres

Realtime Compute for Apache Flink

Elasticsearch

Vector Retrieval Service for Milvus

E-MapReduce

Data Lake Formation

DataV

Quick BI

Quick Audience

Quick Tracking

DataWorks

DataHub

Dataphin

Media Services

ApsaraVideo VOD

ApsaraVideo Live

Intelligent Media Services

ApsaraVideo Media Processing

Apsara Video SDK

Enterprise Services & Cloud Communication

Energy Expert

CloudQuotation

Salesforce on Alibaba Cloud

GoChina ICP Filing Assistant

Marketplace

Alibaba Mail

Direct Mail

Short Message Service

Voice Service

Phone Number Verification Service

Cell Phone Number Service

Chat App Message Service

Financial Intelligence Engine

Domain Names and Websites

Domain Names

ICP Filing

Alibaba Cloud DNS

End User Computing

Elastic Desktop Service

App Streaming

WUYING Terminal

Cloud Phone

AgentBay

Internet of Things

IoT Platform

Serverless

Serverless App Engine

CloudFlow

EventBridge

Simple Message Queue (formerly MNS)

Function Compute

Developer Tools

OpenAPI Explorer

Alibaba Cloud SDK

Cloud Shell

Resource Orchestration Service

Alibaba Cloud CLI

BSS OpenAPI

Terraform

Pulumi

Ticket System API

Mobile Platform as a Service

Alibaba Cloud DevOps

API Gateway

Cloud Control API

AI Coding Assistant Lingma

Cloud Skills Portal

Migration & O&M Management

CloudOps Orchestration Service

Cloud Monitor

Intelligent Advisor

Cloud Governance Center

ActionTrail

Cloud Config

Resource Access Management

Resource Management

Cloud Architect Design Tools

Migration Hub

Server Migration Center

Service Catalog

Logic Composer

Quota Center

CloudSSO

HTTPDNS

Solutions

SAP

SuperApp

OpenLake

Membership Service

Expenses and Costs

Account Center

More

Support

Legal

Tech Share Terms and Conditions

After Sales Support

China Gateway Program

Service Level Objectives

Management Console

Security Control

Migrate your Anthropic application to Model Studio by changing three settings. This topic covers the request and response parameters with code examples.

To migrate an existing Anthropic application to Model Studio, change these settings:

  • api_key: Replace with the Model Studio API key.

  • base_url: Replace with a Model Studio endpoint listed below.

  • model: Replace with a supported model name, such as qwen3.7-plus.

Singapore

China (Beijing)

US (Virginia)

Germany (Frankfurt)

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

HTTP request URL:POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages

Replace {WorkspaceId} with your actual workspace ID.

Important

The legacy Singapore URL https://dashscope-intl.aliyuncs.com/apps/anthropic will be deprecated soon. Please migrate to the new URL https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic.

SDK base_url:https://dashscope.aliyuncs.com/apps/anthropic

HTTP request URL:POST https://dashscope.aliyuncs.com/apps/anthropic/v1/messages

SDK base_url:https://dashscope-us.aliyuncs.com/apps/anthropic

HTTP request URL:POST https://dashscope-us.aliyuncs.com/apps/anthropic/v1/messages

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

HTTP request URL:POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/apps/anthropic/v1/messages

Replace {WorkspaceId} with your actual Workspace ID.

Authentication: Pass your Model Studio API key in either the x-api-key header or the Authorization: Bearer header.

## Request BodyBasic Call Streaming Extended Thinking Image Understanding Video Understanding Function calling Prompt Caching Python TypeScript curl python import anthropic import os client = anthropic.Anthropic( api_key=os.getenv("DASHSCOPE_API_KEY"), # Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", ) message = client.messages.create( model="qwen3.7-plus", max_tokens=1024, system="You are a helpful assistant", messages=[ { "role": "user", "content": "Who are you?" } ], thinking={"type": "disabled"}, ) print(message.content[0].text) typescript import Anthropic from "@anthropic-ai/sdk"; const anthropic = new Anthropic({ apiKey: process.env.DASHSCOPE_API_KEY, // Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", }); async function main() { const message = await anthropic.messages.create({ model: "qwen3.7-plus", max_tokens: 1024, system: "You are a helpful assistant", messages: [{ role: "user", content: "Who are you?" }], thinking: { type: "disabled" }, }); console.log(message.content[0].text); } main().catch(console.error); curl 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": "qwen3.7-plus", "max_tokens": 1024, "system": "You are a helpful assistant", "messages": [ { "role": "user", "content": "Who are you?" } ], "thinking": {"type": "disabled"} }' Python TypeScript curl python import anthropic import os client = anthropic.Anthropic( api_key=os.getenv("DASHSCOPE_API_KEY"), # Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", ) stream = client.messages.create( model="qwen3.7-plus", max_tokens=1024, stream=True, messages=[ { "role": "user", "content": "Give a brief introduction to artificial intelligence." } ], 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) typescript import Anthropic from "@anthropic-ai/sdk"; async function main() { const anthropic = new Anthropic({ apiKey: process.env.DASHSCOPE_API_KEY, // Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", }); const stream = await anthropic.messages.create({ model: "qwen3.7-plus", max_tokens: 1024, stream: true, messages: [{ role: "user", content: "Give a brief introduction to artificial intelligence." }], 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 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": "qwen3.7-plus", "max_tokens": 1024, "stream": true, "messages": [ { "role": "user", "content": "Give a brief introduction to artificial intelligence." } ], "thinking": {"type": "disabled"} }' Python TypeScript curl python import anthropic import os client = anthropic.Anthropic( api_key=os.getenv("DASHSCOPE_API_KEY"), # Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", ) stream = client.messages.create( model="qwen3.7-plus", max_tokens=2048, stream=True, thinking={ "type": "enabled", "budget_tokens": 1024 }, messages=[ { "role": "user", "content": "Analyze the future prospects of quantum computing." } ] ) 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) typescript import Anthropic from "@anthropic-ai/sdk"; async function main() { const anthropic = new Anthropic({ apiKey: process.env.DASHSCOPE_API_KEY, // Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", }); const stream = await anthropic.messages.create({ model: "qwen3.7-plus", max_tokens: 2048, stream: true, thinking: { type: "enabled", budget_tokens: 1024 }, messages: [{ role: "user", content: "Analyze the future prospects of quantum computing." }] }); 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 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": "qwen3.7-plus", "max_tokens": 2048, "stream": true, "thinking": { "type": "enabled", "budget_tokens": 1024 }, "messages": [ { "role": "user", "content": "Analyze the future prospects of quantum computing." } ] }' Python TypeScript curl python import anthropic import os client = anthropic.Anthropic( api_key=os.getenv("DASHSCOPE_API_KEY"), # Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", ) stream = client.messages.create( model="qwen3.7-plus", 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": "Describe the content of this image." }, ], } ], 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) typescript import Anthropic from "@anthropic-ai/sdk"; async function main() { const anthropic = new Anthropic({ apiKey: process.env.DASHSCOPE_API_KEY, // Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", }); const stream = await anthropic.messages.create({ model: "qwen3.7-plus", 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: "Describe the content of this image." }, ], }], 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 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": "qwen3.7-plus", "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": "Describe the content of this image." } ] } ], "thinking": {"type": "disabled"} }' Python TypeScript curl python import anthropic import os client = anthropic.Anthropic( api_key=os.getenv("DASHSCOPE_API_KEY"), # Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", ) stream = client.messages.create( model="qwen3.7-plus", 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": "Describe the content of this video." }, ], } ], 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) typescript import Anthropic from "@anthropic-ai/sdk"; async function main() { const anthropic = new Anthropic({ apiKey: process.env.DASHSCOPE_API_KEY, // Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", }); const stream = await anthropic.messages.create({ model: "qwen3.7-plus", 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: "Describe the content of this video." }, ], }], 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 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": "qwen3.7-plus", "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": "Describe the content of this video." } ] } ], "thinking": {"type": "disabled"} }' Python TypeScript curl python import anthropic import os client = anthropic.Anthropic( api_key=os.getenv("DASHSCOPE_API_KEY"), # Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", ) tools = [ { "name": "get_weather", "description": "Get weather information for a specified city", "input_schema": { "type": "object", "properties": { "city": { "type": "string", "description": "City name" } }, "required": ["city"] } } ] message = client.messages.create( model="qwen3.7-plus", max_tokens=1024, tools=tools, messages=[ { "role": "user", "content": "What's the weather like in Hangzhou today?" } ] ) print(message.content) typescript import Anthropic from "@anthropic-ai/sdk"; async function main() { const anthropic = new Anthropic({ apiKey: process.env.DASHSCOPE_API_KEY, // Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", }); const message = await anthropic.messages.create({ model: "qwen3.7-plus", max_tokens: 1024, tools: [ { name: "get_weather", description: "Get weather information for a specified city", input_schema: { type: "object", properties: { city: { type: "string", description: "City name" } }, required: ["city"], }, }, ], messages: [{ role: "user", content: "What's the weather like in Hangzhou today?" }], }); console.log(JSON.stringify(message.content, null, 2)); } main().catch(console.error); curl 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": "qwen3.7-plus", "max_tokens": 1024, "tools": [ { "name": "get_weather", "description": "Get weather information for a specified city", "input_schema": { "type": "object", "properties": { "city": { "type": "string", "description": "City name" } }, "required": ["city"] } } ], "messages": [ { "role": "user", "content": "What's the weather like in Hangzhou today?" } ] }' Python TypeScript curl python import anthropic import os client = anthropic.Anthropic( api_key=os.getenv("DASHSCOPE_API_KEY"), # Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", ) # Simulate code repository content. Must reach minimum cacheable length (1024 tokens) long_text_content = "<Your Code Here>" * 400 def get_completion(user_input): response = client.messages.create( # Choose a model that supports prompt caching model="qwen3.7-plus", max_tokens=1024, system=[ { "type": "text", "text": long_text_content, # Add cache_control on a text block to mark a cache breakpoint. Can also be placed on content blocks in the messages array "cache_control": {"type": "ephemeral"}, } ], messages=[ {"role": "user", "content": user_input}, ], ) return response # First request: Create cache first = get_completion("What does this code do?") print(f"Cache creation tokens: {first.usage.cache_creation_input_tokens}") print(f"Cache read tokens: {first.usage.cache_read_input_tokens}") print("=" * 20) # Second request: Same long content, different question -> Cache hit second = get_completion("How can this code be optimized?") print(f"Cache creation tokens: {second.usage.cache_creation_input_tokens}") print(f"Cache read tokens: {second.usage.cache_read_input_tokens}") typescript import Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic({ apiKey: process.env.DASHSCOPE_API_KEY, // Replace {WorkspaceId} with your actual workspace ID. URLs vary by region. baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic", }); // Simulate code repository content. Must reach minimum cacheable length (1024 tokens) const longTextContent = "<Your Code Here>".repeat(400); async function getCompletion(userInput) { return client.messages.create({ // Choose a model that supports prompt caching model: "qwen3.7-plus", max_tokens: 1024, system: [ { type: "text", text: longTextContent, // Add cache_control on a text block to mark a cache breakpoint. Can also be placed on content blocks in the messages array cache_control: { type: "ephemeral" }, }, ], messages: [{ role: "user", content: userInput }], }); } // First request: Create cache const first = await getCompletion("What does this code do?"); 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)); // Second request: Same long content, different question -> Cache hit const second = await getCompletion("How can this code be optimized?"); console.log(`Cache creation tokens: ${second.usage.cache_creation_input_tokens}`); console.log(`Cache read tokens: ${second.usage.cache_read_input_tokens}`); curl 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": "qwen3.7-plus", "max_tokens": 1024, "system": [ { "type": "text", "text": "<Place cacheable content here with at least 1024 tokens>", "cache_control": {"type": "ephemeral"} } ], "messages": [ {"role": "user", "content": "What does this code do?"} ] }'
modelstring (Required) Model name. Supported models: Supported Models Qwen-Max: qwen3.7-max, qwen3.7-max-2026-05-20, qwen3.7-max-2026-06-08, qwen3.6-max-preview, qwen3-max, qwen3-max-2026-01-23, qwen3-max-preview 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-plus-2025-09-11 Qwen-Flash: 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-Turbo: qwen-turbo Qwen-Coder: qwen3-coder-next, qwen3-coder-plus, qwen3-coder-plus-2025-09-23, qwen3-coder-flash Qwen-VL: qwen3-vl-plus, qwen3-vl-flash, qwen-vl-max, qwen-vl-plus Qwen Open-Source Models: qwen3.6-27b, qwen3.5-397b-a17b, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b Third-Party Models deepseek-v4-pro, deepseek-v4-flash, kimi-k2.5, kimi-k2-thinking, glm-5.1, glm-5, glm-4.7, glm-4.6, MiniMax-M2.5, MiniMax-M2.1
max_tokensinteger (Required) Maximum number of tokens for the reply content. If the generated content exceeds this value, generation stops early and stop_reason is max_tokens. > max_tokens does not limit the length of the thinking process. When extended thinking is enabled, the thinking tokens are controlled separately by thinking.budget_tokens.
systemstring or array (Optional) System prompt that defines model behavior. system is a top-level parameter — the messages array does not accept a system role. A string equals a single type="text" block. Pass an array to mark prompt caching breakpoints. Properties typestring (Required) Fixed value: text. textstring (Required) The system prompt text. cache_controlobject (Optional) Prompt caching breakpoint. On cache hit, subsequent requests are billed at the cache read rate. Contains only type, fixed to ephemeral.
messagesarray (Required) The message array, arranged in alternating user/assistant turns. messages array element rolestring (Required) The message role. Valid values: user, assistant. contentstring or array (Required) Plain text string or structured content array. A string equals a single content block with type="text". content array element types Text Properties typestring (Required) Fixed value: text. textstring (Required) The text content. cache_controlobject (Optional) Prompt caching breakpoint. Contains only type, fixed to ephemeral. Image (requires vision model) Properties typestring (Required) Fixed value: image. sourceobject (Required) The source of the image data. Properties typestring (Required) Valid values: url (public image URL), base64 (Base64-encoded). urlstring The public URL of the image. Required when type is url. media_typestring The MIME type of the image, such as image/jpeg. Required when type is base64. datastring The Base64-encoded image data. Required when type is base64. Video (requires vision model) Properties typestring (Required) Fixed value: video. sourceobject (Required) The source of the video data. Properties typestring (Required) Valid values: url (public video URL), base64 (Base64-encoded). urlstring The public URL of the video. Required when type is url. media_typestring The MIME type of the video, such as video/mp4. Required when type is base64. datastring The Base64-encoded video data. Required when type is base64. Tool use (assistant role; tool call instruction returned by the model) Properties typestring (Required) Fixed value: tool_use. idstring (Required) The unique identifier of the tool call, used to associate the result in a subsequent tool_result. namestring (Required) The name of the called tool. inputobject (Required) The input parameters of the tool call. The structure is determined by the input_schema of the corresponding tool in tools. cache_controlobject (Optional) Prompt caching breakpoint. Contains only type, fixed to ephemeral. The tool call content participates in the cache prefix. Tool result (user role; execution result of a tool sent back to the model) Properties typestring (Required) Fixed value: tool_result. tool_use_idstring (Required) Corresponds to the id in the tool_use block. contentstring (Required) Content returned by the tool. cache_controlobject (Optional) Prompt caching breakpoint. Contains only type, fixed to ephemeral.
streamboolean (Optional) Whether to enable streaming. Default value: false.
temperaturenumber (Optional) Controls the diversity of generated text. Value range: [0, 2). Higher values produce more random results. Note This range is different from the official Anthropic range of [0.0, 1.0]. When migrating from Anthropic, verify the value of this parameter.\
top_pnumber (Optional) Nucleus sampling probability threshold. > Both temperature and top_p can control the diversity of generated text. We recommend setting only one of them. For more information, see Overview.\
top_kinteger (Optional) Candidate set size during sampling.\
stop_sequencesarray (Optional) Text sequences that trigger generation to stop. Output ends before the matched sequence. Note After a match, the stop_reason in the response is still end_turn, and the response does not include the matched sequence.\
thinkingobject (Optional) Extended thinking configuration. When enabled, the model reasons before responding, and the response includes thinking-type content blocks. Not all models support thinking mode. Properties typestring (Required) Valid values: enabled (enable thinking mode), disabled (disable thinking mode). budget_tokensinteger (Optional) Maximum tokens for the thinking process. Disjoint from max_tokens: this parameter limits the thinking portion, while max_tokens limits the final reply. A larger budget allows more thorough analysis on complex questions. Takes effect when type is enabled.\
reasoning_effortstring (Optional) Controls the reasoning intensity of the model. Valid values: high, max. Default value: max. Supported models: deepseek-v4-pro, deepseek-v4-flash. Note When set to low or medium, it is mapped to high. When set to xhigh, it is mapped to max.\
toolsarray (Optional) Tool definitions for function calling. tools array element namestring (Required) The tool name. descriptionstring (Optional) The description of the tool function. input_schemaobject (Required) The JSON Schema definition of the tool input parameters.\
tool_choiceobject (Optional) Tool selection strategy: - {"type": "auto"}: The model decides whether to call a tool (default). - {"type": "any"}: Force the model to call any tool. - {"type": "none"}: Prohibit the model from calling tools. - {"type": "tool", "name": "tool_name"}: Force the model to call a specified tool.\
\
------
## Non-streaming ResponseResponse Example json { "id": "msg_e2898f19-fc0e-4cb3-bd9b-5b7dc4ea3bc9", "type": "message", "role": "assistant", "model": "qwen3.7-plus", "content": [ { "type": "thinking", "thinking": "Let me analyze this problem...", "signature": "" }, { "type": "text", "text": "Hello! I am 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 } }
idstring Unique message identifier.\
typestring Fixed value: message.\
rolestring Fixed value: assistant.\
modelstring The model used for generation.\
contentarray The content array. content array element types Text Properties typestring Fixed value: text. textstring The text response generated by the model. Thinking (returned when Extended Thinking is enabled) Properties typestring Fixed value: thinking. thinkingstring The model's reasoning before the final response. signaturestring Currently fixed as an empty string. Tool use (function call scenario) Properties typestring Fixed value: tool_use. idstring Unique tool call identifier, used to match the tool_result. namestring The name of the called tool. inputobject The input parameters of the tool call.\
stop_reasonstring Reason generation stopped. Valid values: end_turn (normal completion), max_tokens (token limit reached), tool_use (tool call).\
stop_sequencestring Always null.\
usageobject Token usage statistics. Note In streaming calls, the usage field of the message_start event contains only input_tokens and output_tokens. The full four fields are returned in the message_delta event. Properties input_tokensinteger Input tokens. output_tokensinteger Output tokens. cache_creation_input_tokensinteger Tokens consumed for cache creation. cache_read_input_tokensinteger Tokens consumed from cache reads.
\
------
## Streaming ResponseStreaming response example json {"type":"message_start","message":{"id":"msg_xxx","type":"message","role":"assistant","model":"qwen3.7-plus","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":"Here's a thinking process:\n\n1. **Analyze User Input:**\n - **Topic:** Artificial Intelligence (AI)\n - **Request:** Give a brief introduction to artificial intelligence."}} {"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":"Artificial intelligence (AI) is an important branch of computer science..."}} {"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"}
message_start First stream event, marks message start. Properties typestring Fixed value: message_start. messageobject The initial message object. content is an empty array, and usage contains only input_tokens and output_tokens.\
content_block_start Marks the start of a content block. Properties typestring Fixed value: content_block_start. indexinteger 0-based index corresponding to position in the content array. content_blockobject The initial object of the content block. The type value is text, thinking, or tool_use. For the tool_use type, the input field is an empty object in this event, and the complete input parameters are assembled from subsequent content_block_delta deltas.\
content_block_delta Incremental content block update. Multiple deltas sent per block. Properties typestring Fixed value: content_block_delta. indexinteger The index of the associated content block. deltaobject Delta object. type values: - text_delta: Text delta, containing the text field. - thinking_delta: Thinking delta, containing the thinking field. - signature_delta: Signature delta, containing the signature field (currently fixed as an empty string). - input_json_delta: Tool call input parameter delta, containing the partial_json field.\
content_block_stop Marks the end of a content block. Properties typestring Fixed value: content_block_stop. indexinteger The index of the ended content block.\
message_delta Sent after all content blocks end. Contains stop reason and final token usage. Properties typestring Fixed value: message_delta. deltaobject Contains stop_reason and stop_sequence. For valid values, see the Non-streaming Response table above. usageobject Complete token usage statistics, including input_tokens, output_tokens, cache_creation_input_tokens, and cache_read_input_tokens.\
message_stop Final event, marks message end. Properties typestring Fixed value: message_stop. In addition, streaming responses periodically send ping events ({"type":"ping"}) to keep the connection alive. Clients can ignore them.\
\
Previous: List input itemsNext: DashScope\
\
Is this page helpful?\
\

\


Request Body

Non-streaming Response

Streaming Response





Contact Us


\

Sales Support\


Live-chat with our sales team or get in touch with a business development professional in your region.

Contact Sales
\

Technical Support\


Open a ticket and get quick help from our technical team.

Open a Ticket >
\

Connect & Report Abuse\


We look forward to your suggestion.

Post a Suggestion > Report Abuse >

\ \ Hi, I'm Alibaba Cloud AI Assistant!\ \ I can help with questions and solutions.

Why Alibaba Cloud

About Alibaba Cloud

Asia Accelerator

Our Global Network

Global Offices

Trust Center

Case Studies

Analyst Reports

Products & Pricings

Pricing Calculator

ECS

SAS

Model Studio

Database

Security

SMS

Solutions

Financial Services

Retail Services

Media Services

Gaming Services

ISV Solutions

Engage

Developer Community

Partner Network

Startups

Marketplace

Join Alibaba Cloud

Resources & Support

Developer Learning Hub

Documentation Center

Training & Certification

Service Notices

Submit a Ticket

Security Report

Qwen Cloud

Careers About Us Privacy Policy Legal Integrity Compliance Reporting Channel Service Notices Links

© 2009-2026 Copyright by Alibaba Cloud All rights reserved
\

  • Facebook\
  • Linkedin\
  • Twitter\
  • YouTube\
  • TikTok\
  • contact.us@alibabacloud.com\
  • Call Us Now\
  • Discord





    © 2009-2026 Copyright by Alibaba Cloud All rights reserved

    Careers About Us Privacy Policy Legal Integrity Compliance Reporting Channel Service Notices Links
    \
\
\