OpenAI-Compatible API

Drop-in replacement for the OpenAI API — migrate in minutes by changing the base URL and API key.

OpenAI-Compatible API

QwenAPI implements the OpenAI Chat Completions API spec. If you're already using the OpenAI Python or Node.js SDK, switching to Qwen models requires changing two lines.

Base URLs

RegionBase URL
Singaporehttps://dashscope-intl.aliyuncs.com/compatible-mode/v1
United Stateshttps://dashscope-us.aliyuncs.com/compatible-mode/v1
Use the US endpoint for lower latency from North America. Both endpoints serve the same models.

Authentication

Pass your QwenAPI key as the Bearer token — the same way you'd pass an OpenAI key:

``bash

Authorization: Bearer YOUR_QWENAPI_KEY

`

Get your API key from the QwenAPI dashboard.

Migration from OpenAI

Before:

`python

from openai import OpenAI

client = OpenAI(api_key="sk-...")

`

After:

`python

from openai import OpenAI

client = OpenAI(

api_key="YOUR_QWENAPI_KEY",

base_url="https://dashscope-us.aliyuncs.com/compatible-mode/v1",

)

`

That's it. All existing calls to client.chat.completions.create(...) work without further changes. Swap the model name to a Qwen model and you're done.

Node.js

`javascript

import OpenAI from "openai";

const client = new OpenAI({

apiKey: process.env.QWENAPI_KEY,

baseURL: "https://dashscope-us.aliyuncs.com/compatible-mode/v1",

});

const response = await client.chat.completions.create({

model: "qwen3.5-plus",

messages: [{ role: "user", content: "Hello!" }],

});

`

Supported Endpoints

EndpointStatus
POST /chat/completionsSupported
POST /completionsSupported
POST /embeddingsSupported
POST /audio/speechSupported
POST /audio/transcriptionsSupported
POST /filesSupported (Batch API)
POST /batchesSupported
GET /modelsSupported

Supported Parameters

All standard OpenAI Chat Completions parameters are supported:

model, messages, temperature, top_p, max_tokens, stream, stop, presence_penalty, frequency_penalty, n, seed, tools, tool_choice, response_format, logprobs

Extra Parameters

Qwen-specific features are passed via extra_body in the SDK (or directly in the JSON body):

ParameterTypeDescription
enable_thinkingbooleanEnable chain-of-thought reasoning (qwen3-max)
enable_searchbooleanGround response with live web search
search_optionsobjectConfigure search behavior (sources, recency)
`python

response = client.chat.completions.create(

model="qwen3-max",

messages=[{"role": "user", "content": "Solve this step by step: ..."}],

extra_body={

"enable_thinking": True,

"enable_search": False,

},

)

`

Tool Calling

Function/tool calling works identically to OpenAI:

`python

tools = [

{

"type": "function",

"function": {

"name": "get_weather",

"description": "Get current weather for a city",

"parameters": {

"type": "object",

"properties": {

"city": {"type": "string"},

},

"required": ["city"],

},

},

}

]

response = client.chat.completions.create(

model="qwen3.5-plus",

messages=[{"role": "user", "content": "What's the weather in Austin?"}],

tools=tools,

tool_choice="auto",

)

`

Structured Output

Use response_format to get guaranteed JSON:

`python

response = client.chat.completions.create(

model="qwen3.5-flash",

messages=[{"role": "user", "content": "List 3 US cities as JSON."}],

response_format={"type": "json_object"},

)

`

Rate Limits

Rate limits are per API key and vary by plan. Limits are returned in response headers:

`

X-RateLimit-Limit-Requests: 1000

X-RateLimit-Remaining-Requests: 998

X-RateLimit-Reset-Requests: 2026-05-14T12:00:00Z

``

Contact support to increase limits for production workloads.