Introduction
The Qwen API lets developers create solutions in text generation, code completion, and multimodal processing under a single, unified interface through Wisdom Gate.
Getting Started
Requirements
- Python 3.8+
- cURL for testing requests
- An API key from Wisdom Gate
Get Your API Key
Visit AI Studio and create an account. Locate your key in account settings.
Base URL and Docs
Use https://wisdom-gate.juheapi.com/v1 as the API base. Review the model page to see features.
Models and Pricing
Compared to other models, Qwen offers competitive rates via Wisdom Gate:
- GPT‑5: $1.00 / $8.00 per 1M tokens (~20% lower than OpenRouter)
- Claude Sonnet 4: $2.00 / $10.00 per 1M tokens (~30% lower)
- qwen3‑max: $1.20 / $6.00 per 1M tokens (~30% lower)
Text Generation with Qwen
Using Python
import requests
url = "https://wisdom-gate.juheapi.com/v1/chat/completions"
headers = {
"Authorization": "YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "qwen3-max",
"messages": [{"role": "user", "content": "Write a short poem about winter"}]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
Using cURL
curl --location --request POST 'https://wisdom-gate.juheapi.com/v1/chat/completions' \
--header 'Authorization: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"model":"qwen3-max","messages":[{"role":"user","content":"Hello, how can you help me today?"}]}'
Tips
- Organize prompts clearly.
- Use
assistantrole for replies andsystemrole for rules.
Code Generation with Qwen
Request Format
Send coding tasks as text prompts. Example:
data = {
"model": "qwen3-max",
"messages": [{"role": "user", "content": "Generate Python code to reverse a list"}]
}
Handling Output
- Parse code from
message.content. - Test the code in a sandbox.
Multimodal Tasks with Qwen
Image Understanding
Provide an image URL or base64 data in messages.content alongside descriptive text.
Combining Text and Image Inputs
Example scenario: "Analyze this chart image and summarize insights." Attach image reference in the same message object.
Wisdom Gate Unified Format
Every endpoint follows the same pattern:
modeldefines the variant.messagesis a list with{role, content}objects.
Benefits:
- Easier client code reuse.
- Consistent parameter names.
Advanced Features
Parameter Tuning
max_tokens: control response length.temperature: randomness in output.top_p: nucleus sampling.
Error Handling
Common HTTP codes:
- 401: Invalid API key.
- 429: Too many requests.
- 500: Server error.
Best Practices
- Respect rate limits.
- Keep keys secure.
- Optimize prompts for lower output tokens to save cost.
Conclusion
With the Qwen API via Wisdom Gate, developers can unify text, code, and image tasks efficiently, saving costs and reducing complexity.