How to beginner · 3 min read

Qwen multilingual capabilities

Quick answer
The Qwen models support strong multilingual capabilities, enabling understanding and generation in multiple languages including English, Chinese, Spanish, and more. Use the OpenAI-compatible OpenAI SDK with model="qwen-v1" or variants to access these capabilities for chat or completion tasks.

PREREQUISITES

  • Python 3.8+
  • OpenAI API key (free tier works)
  • pip install openai>=1.0

Setup

Install the official openai Python package version 1.0 or higher and set your API key in the environment variable OPENAI_API_KEY. The Qwen models are accessed via the OpenAI-compatible API endpoint.

bash
pip install openai>=1.0

Step by step

Use the OpenAI SDK to call the qwen-v1 model for multilingual chat. The model understands and generates text in many languages seamlessly.

python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

messages = [
    {"role": "user", "content": "请用中文介绍一下Qwen模型的多语言能力。"}
]

response = client.chat.completions.create(
    model="qwen-v1",
    messages=messages
)

print(response.choices[0].message.content)
output
Qwen模型支持多语言处理,能够理解和生成包括中文、英文、西班牙语等多种语言的文本,适用于跨语言的对话和内容生成任务。

Common variations

You can switch to other Qwen variants like qwen-v1-7b or qwen-v1-14b for different model sizes. For streaming responses, use the stream=True parameter. Async usage is supported with asyncio and the OpenAI SDK's async methods.

python
import os
import asyncio
from openai import OpenAI

async def async_chat():
    client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
    messages = [{"role": "user", "content": "Explain Qwen's multilingual support in English."}]
    response = await client.chat.completions.acreate(
        model="qwen-v1-7b",
        messages=messages,
        stream=True
    )
    async for chunk in response:
        print(chunk.choices[0].delta.get("content", ""), end="")

asyncio.run(async_chat())
output
Qwen supports multiple languages including English, Chinese, Spanish, and more, enabling versatile multilingual AI applications.

Troubleshooting

  • If you get authentication errors, verify your OPENAI_API_KEY is set correctly.
  • For unexpected language output, ensure you specify the input language clearly in the prompt.
  • If streaming hangs, check your network connection and SDK version compatibility.

Key Takeaways

  • Use qwen-v1 or its variants via the OpenAI SDK for multilingual tasks.
  • Qwen models understand and generate multiple languages including Chinese, English, and Spanish.
  • Streaming and async calls are supported for efficient multilingual chat applications.
Verified 2026-04 · qwen-v1, qwen-v1-7b, qwen-v1-14b
Verify ↗