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.
API Reference
Complete API documentation and method details
Qwen Docs
Official Qwen API documentation and features
Example Code
Working example with function calling
Installation
To use QwenLLMService
, install the required dependencies:
You’ll also need to set up your DashScope API key as an environment variable: QWEN_API_KEY
.
Get your API key from Alibaba Cloud Model Studio.
Frames
Input
OpenAILLMContextFrame
- Conversation context and historyLLMMessagesFrame
- Direct message listVisionImageRawFrame
- Images for vision processingLLMUpdateSettingsFrame
- Runtime parameter updates
Output
LLMFullResponseStartFrame
/LLMFullResponseEndFrame
- Response boundariesLLMTextFrame
- Streamed completion chunksFunctionCallInProgressFrame
/FunctionCallResultFrame
- Function call lifecycleErrorFrame
- API or processing errors
Function Calling
Function Calling Guide
Learn how to implement function calling with standardized schemas, register handlers, manage context properly, and control execution flow in your conversational AI applications.
Context Management
Context Management Guide
Learn how to manage conversation context, handle message history, and integrate context aggregators for consistent conversational experiences.
Usage Example
Metrics
Inherits all OpenAI metrics capabilities:
- Time to First Byte (TTFB) - Response latency measurement
- Processing Duration - Total request processing time
- Token Usage - Prompt tokens, completion tokens, and totals
Enable with:
Additional Notes
- OpenAI Compatibility: Full compatibility with OpenAI API features and parameters
- Long Context Support: Models support up to 1M token contexts for extensive conversations
- Multilingual Excellence: Superior performance in Chinese with strong English capabilities
- Code-Switching: Seamlessly handles mixed Chinese-English conversations
- Alibaba Cloud Integration: Native integration with Alibaba Cloud ecosystem