> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipecat.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Qwen

> LLM service implementation using Alibaba Cloud's Qwen models through an OpenAI-compatible interface

## Overview

`QwenLLMService` provides access to Alibaba Cloud's Qwen language models through an OpenAI-compatible interface. It inherits from `OpenAILLMService` and supports streaming responses, function calling, and context management, with particularly strong capabilities for Chinese language processing.

<CardGroup cols={2}>
  <Card title="Qwen LLM API Reference" icon="code" href="https://reference-server.pipecat.ai/en/latest/api/pipecat.services.qwen.llm.html">
    Pipecat's API methods for Qwen integration
  </Card>

  <Card title="Example Implementation" icon="play" href="https://github.com/pipecat-ai/pipecat/blob/main/examples/function-calling/function-calling-qwen.py">
    Complete example with function calling
  </Card>

  <Card title="Qwen Documentation" icon="book" href="https://www.alibabacloud.com/help/en/model-studio/use-qwen-by-calling-api">
    Official Qwen API documentation and features
  </Card>

  <Card title="Alibaba Cloud Console" icon="microphone" href="https://www.alibabacloud.com/">
    Access Qwen models and manage API keys
  </Card>
</CardGroup>

## Installation

To use Qwen services, install the required dependencies:

```bash theme={null}
uv add "pipecat-ai[qwen]"
```

## Prerequisites

### Qwen Account Setup

Before using Qwen LLM services, you need:

1. **Alibaba Cloud Account**: Sign up at [Alibaba Cloud](https://www.alibabacloud.com/)
2. **API Key**: Generate an API key from your Model Studio dashboard
3. **Model Selection**: Choose from available Qwen models with multilingual capabilities

### Required Environment Variables

* `QWEN_API_KEY`: Your Qwen API key for authentication

## Configuration

<ParamField path="api_key" type="str" required>
  Qwen (DashScope) API key for authentication.
</ParamField>

<ParamField path="base_url" type="str" default="https://dashscope-intl.aliyuncs.com/compatible-mode/v1">
  Base URL for Qwen API endpoint.
</ParamField>

<ParamField path="model" type="str" default="None" deprecated>
  *Deprecated in v0.0.105. Use `settings=QwenLLMService.Settings(model=...)`
  instead.*
</ParamField>

<ParamField path="settings" type="QwenLLMService.Settings" default="None">
  Runtime-configurable settings. See [Settings](#settings) below.
</ParamField>

### Settings

Runtime-configurable settings passed via the `settings` constructor argument using `QwenLLMService.Settings(...)`. These can be updated mid-conversation with `LLMUpdateSettingsFrame`. See [Service Settings](/pipecat/fundamentals/service-settings) for details.

This service uses the same settings as `OpenAILLMService`. See [OpenAI LLM Settings](/api-reference/server/services/llm/openai#settings) for the full parameter reference.

## Usage

### Basic Setup

```python theme={null}
import os
from pipecat.services.qwen import QwenLLMService

llm = QwenLLMService(
    api_key=os.getenv("QWEN_API_KEY"),
    model="qwen-plus",
)
```

### With Custom Settings

```python theme={null}
from pipecat.services.qwen import QwenLLMService

llm = QwenLLMService(
    api_key=os.getenv("QWEN_API_KEY"),
    settings=QwenLLMService.Settings(
        model="qwen-plus",
        temperature=0.7,
        top_p=0.9,
        max_completion_tokens=1024,
    ),
)
```

## Notes

* Qwen models are particularly strong for Chinese language processing and multilingual tasks.
* Qwen fully supports the OpenAI-compatible parameter set inherited from `OpenAILLMService`.
* The API endpoint uses the DashScope international URL by default. For users in mainland China, you may want to override `base_url` with the domestic endpoint.

<Tip>
  The `InputParams` / `params=` pattern is deprecated as of v0.0.105. Use
  `Settings` / `settings=` instead. See the [Service Settings
  guide](/pipecat/fundamentals/service-settings) for migration details.
</Tip>
