Blog Article

Qwen 3.5 API: Access Qwen Models via OpenRouter and Alibaba Cloud

How to access Qwen 3.5 through APIs including OpenRouter and Alibaba Cloud DashScope. Covers API keys, Python and curl examples, pricing, and model IDs for qwen 3.5 api integration.

Qwen 3.5 API: Access Qwen Models via OpenRouter and Alibaba Cloud

Qwen 3.5 API: Access Qwen Models via OpenRouter and Alibaba Cloud

If you are searching for qwen 3.5 api, you want to call Qwen 3.5 models programmatically without managing your own infrastructure. There are two main paths: OpenRouter, which aggregates multiple model providers behind a single API, and Alibaba Cloud DashScope, which is the official first-party API from the Qwen team.

This guide covers both options with working code examples. If you just want to chat with Qwen 3.5 without any code at all, you can try Qwen 3.5 free in the browser.

API options overview

ProviderEndpoint StyleKey Advantage
OpenRouterOpenAI-compatibleSingle API key for many models, easy switching
Alibaba Cloud DashScopeOpenAI-compatibleFirst-party, official Qwen API, competitive pricing

Both providers expose OpenAI-compatible endpoints, which means your existing code that works with the OpenAI SDK can be pointed at Qwen 3.5 with minimal changes.

Using Qwen 3.5 via OpenRouter

OpenRouter is a popular choice because it lets you access models from many providers through one API. Qwen 3.5 models are available alongside models from other families, making it easy to compare and switch.

Getting an API key

  1. Go to openrouter.ai
  2. Sign up or log in
  3. Navigate to the API keys section
  4. Create a new API key

Python example with OpenRouter

import openai

client = openai.OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key="your-openrouter-api-key"
)

response = client.chat.completions.create(
    model="qwen/qwen3.5-7b-instruct",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain the key improvements in Qwen 3.5."}
    ],
    max_tokens=512
)

print(response.choices[0].message.content)

curl example with OpenRouter

curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer your-openrouter-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen/qwen3.5-7b-instruct",
    "messages": [
      {"role": "user", "content": "What is mixture of experts?"}
    ],
    "max_tokens": 256
  }'

OpenRouter model IDs for Qwen 3.5

Common model IDs on OpenRouter (check their model list for the latest):

  • qwen/qwen3.5-7b-instruct
  • qwen/qwen3.5-32b-instruct
  • qwen/qwen3.5-72b-instruct

The exact model IDs may vary as OpenRouter updates their catalog. Check the OpenRouter model page for the current list.

Using Qwen 3.5 via Alibaba Cloud DashScope

DashScope is Alibaba Cloud's AI model service platform and the official home for the Qwen API. It typically offers the widest selection of Qwen models and competitive pricing.

Getting an API key

  1. Go to dashscope.aliyuncs.com
  2. Create an Alibaba Cloud account (or sign in)
  3. Enable the DashScope service
  4. Generate an API key from the console

Python example with DashScope

DashScope also supports the OpenAI-compatible format:

import openai

client = openai.OpenAI(
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    api_key="your-dashscope-api-key"
)

response = client.chat.completions.create(
    model="qwen3.5-7b-instruct",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Compare dense and MoE model architectures."}
    ],
    max_tokens=512
)

print(response.choices[0].message.content)

curl example with DashScope

curl https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \
  -H "Authorization: Bearer your-dashscope-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.5-7b-instruct",
    "messages": [
      {"role": "user", "content": "What is PagedAttention?"}
    ],
    "max_tokens": 256
  }'

DashScope model IDs for Qwen 3.5

Common model IDs on DashScope:

  • qwen3.5-7b-instruct
  • qwen3.5-14b-instruct
  • qwen3.5-32b-instruct
  • qwen3.5-72b-instruct
  • qwen3.5-moe-a3b-instruct

DashScope often has the most complete selection since it is the first-party provider.

Pricing overview

API pricing varies by provider and model size. Here is a general guide:

ModelProviderInput (per 1M tokens)Output (per 1M tokens)
Qwen3.5-7B-InstructOpenRouter~$0.10~$0.10
Qwen3.5-32B-InstructOpenRouter~$0.30~$0.30
Qwen3.5-7B-InstructDashScope~$0.05~$0.10
Qwen3.5-32B-InstructDashScope~$0.20~$0.40

These prices are approximate and change frequently. Always check the provider's current pricing page for accurate numbers. DashScope often offers free trial credits for new users.

Streaming responses

Both providers support streaming, which is essential for chat applications:

stream = client.chat.completions.create(
    model="qwen3.5-7b-instruct",
    messages=[
        {"role": "user", "content": "Write a short poem about AI."}
    ],
    max_tokens=256,
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

This works identically with both OpenRouter and DashScope since they both follow the OpenAI streaming format.

Choosing between API providers

Choose OpenRouter when:

  • You want one API key for multiple model providers
  • You are comparing Qwen 3.5 against models from other families
  • You value a unified billing and rate limiting experience

Choose DashScope when:

  • You want the official first-party API
  • You need access to the full range of Qwen models
  • You want the most competitive pricing for Qwen specifically
  • You are already in the Alibaba Cloud ecosystem

Choose the browser when:

  • You just want to try Qwen 3.5 without any code
  • You are evaluating which model size fits your needs
  • You want to try Qwen 3.5 free before committing to an API integration

Quick FAQ

Can I use the OpenAI Python SDK with Qwen 3.5 APIs?

Yes. Both OpenRouter and DashScope support the OpenAI-compatible format. Just change the base_url and api_key, and update the model name.

Is there a free tier?

DashScope typically offers free trial credits for new accounts. OpenRouter pricing starts very low for smaller models. Check each provider for current offers.

Which model ID should I use?

For most chat and general tasks, the Instruct variants are the right choice. Start with the 7B model for cost efficiency, and scale up to 32B or larger if quality needs to improve.

Can I use function calling with Qwen 3.5 APIs?

Yes, Qwen 3.5 Instruct models support function calling (tool use) through the standard OpenAI-compatible format. Both OpenRouter and DashScope pass through these capabilities.

Q-Chat Team

Q-Chat Team

Qwen 3.5 API: Access Qwen Models via OpenRouter and Alibaba Cloud | Qwen Blog