Skip to main content

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.

Installation

To use Qwen services, install the required dependencies:
pip install "pipecat-ai[qwen]"

Prerequisites

Qwen Account Setup

Before using Qwen LLM services, you need:
  1. Alibaba Cloud Account: Sign up at Alibaba Cloud
  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

api_key
str
required
Qwen (DashScope) API key for authentication.
base_url
str
Base URL for Qwen API endpoint.
model
str
default:"qwen-plus"
Model identifier to use.

InputParams

This service uses the same input parameters as OpenAILLMService. See OpenAI LLM for details.

Usage

Basic Setup

import os
from pipecat.services.qwen import QwenLLMService

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

With Custom Parameters

from pipecat.services.qwen import QwenLLMService

llm = QwenLLMService(
    api_key=os.getenv("QWEN_API_KEY"),
    model="qwen-plus",
    params=QwenLLMService.InputParams(
        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.