feat: add Qwen (Alibaba Cloud DashScope) provider#898
Open
leslieeilsel wants to merge 1 commit intoprism-php:mainfrom
Open
feat: add Qwen (Alibaba Cloud DashScope) provider#898leslieeilsel wants to merge 1 commit intoprism-php:mainfrom
leslieeilsel wants to merge 1 commit intoprism-php:mainfrom
Conversation
Add comprehensive support for Alibaba Cloud's Qwen models via the DashScope native API (/api/v1), covering text generation, streaming, structured output, embeddings, image generation, and image editing. Key features: - Text generation with multi-step tool calling - Multi-modal (VL) support with automatic endpoint routing - Streaming with DashScope SSE protocol and reasoning/thinking tokens - Structured output with both JSON Object and JSON Schema modes - Embeddings with configurable dimensions - Image generation (qwen-image-max/plus) and editing (qwen-image-edit) - Region-aware configuration (International, China, US deployments) - 52 tests with real API fixtures (176 assertions) Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add comprehensive support for Alibaba Cloud's Qwen models via the DashScope native API (
/api/v1), providing full feature parity with other major providers.Capabilities
qwen-image-max,qwen-image-plusArchitecture
text-generationandmultimodal-generationendpoints based on message content (images present → multimodal endpoint)X-DashScope-SSEheader,incremental_outputmode)response_format: {"type": "json_object"}(broad model support) andresponse_format: {"type": "json_schema", ...}(strict schema enforcement for newer models)Files
src/Providers/Qwen/— 14 files (handlers, maps, concerns)config/prism.php,src/PrismManager.php,src/Enums/Provider.phptests/Providers/Qwen/— 9 test files, 52 tests with 176 assertionstests/Fixtures/qwen/— 14 fixture files recorded from real Qwen API responsesdocs/providers/qwen.md+ updates tostructured-output.md,text-generation.md,image-generation.md,introduction.md,ProviderSupport.vueDesign Decisions
Native API over OpenAI-compatible mode: The DashScope native API is more actively maintained by Alibaba Cloud and provides better feature coverage (multimodal, image editing, structured output modes). The OpenAI-compatible mode lacks some features and has different error response formats.
Dynamic multimodal endpoint routing: Rather than requiring users to manually select endpoints, the handlers inspect message content and automatically route to the correct DashScope endpoint. This keeps the user-facing API clean and consistent with other Prism providers.
No audio support: DashScope's TTS (CosyVoice) uses WebSocket and STT (Paraformer) uses async REST with task polling — neither is compatible with Prism's synchronous HTTP interface. This is clearly documented with alternatives.
Test Plan
Made with Cursor