Skip to main content
Chat Models

DashScope chat

Native SDK and HTTP API

POST
/api/v1/services/aigc/text-generation/generation
import os
import dashscope

dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
messages = [
  {'role': 'system', 'content': 'You are a helpful assistant.'},
  {'role': 'user', 'content': 'Who are you?'}
]
response = dashscope.Generation.call(
  api_key=os.getenv('DASHSCOPE_API_KEY'),
  model='qwen3.6-plus',
  messages=messages,
  result_format='message'
)
print(response)
{
  "status_code": 200,
  "request_id": "902fee3b-f7f0-9a8c-96a1-6b4ea25af114",
  "code": "",
  "message": "",
  "output": {
    "text": null,
    "finish_reason": null,
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "I am a large-scale language model developed by Alibaba Cloud. My name is Qwen.",
          "tool_calls": null,
          "reasoning_content": null
        }
      }
    ]
  },
  "usage": {
    "input_tokens": 22,
    "output_tokens": 17,
    "total_tokens": 39,
    "image_tokens": null,
    "video_tokens": null,
    "audio_tokens": null
  }
}

Endpoint

  • HTTP (text-only, such as qwen-plus): POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/text-generation/generation
  • HTTP (multimodal, such as qwen3.6-plus, qwen3-vl-plus): POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
  • SDK base_http_api_url: https://dashscope-intl.aliyuncs.com/api/v1
Python SDK:
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
Java SDK:
// Option 1: Set during instantiation
import com.alibaba.dashscope.protocol.Protocol;
Generation gen = new Generation(Protocol.HTTP.getValue(), "https://dashscope-intl.aliyuncs.com/api/v1");

// Option 2: Set globally
import com.alibaba.dashscope.utils.Constants;
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";

Authorizations

string
header
required

Your DashScope API key. See Get API key for details.

Body

application/json
string
required

The name of the model to call. Supports Qwen large language models (commercial and open-source), Qwen-Coder, and math models. For a list of models, see Text generation — Qwen.

qwen3.6-plus
object
required

The input to the model.

object

Optional generation parameters for text models.

Response

200-application/json
integer

The status code of the request. 200 indicates success. The Java SDK does not return this field; if a call fails, an exception is thrown containing the status_code.

string

A unique identifier for this request. In the Java SDK, this is requestId.

string

The error code. Empty string if the request was successful. Only the Python SDK returns this field.

string

A human-readable error message. Empty string if the request was successful.

object

The model's output.

object

Token usage information for this request.

DashScope chat | Qwen Cloud