Your First Qwen Call on the Aggregator: The Smallest Request That Proves Routing Works
Make your first Qwen API call through the aggregator with a minimal chat completion request. Learn to construct the messages array, specify the model alias, and interpret response fields to confirm routing to Qwen.
Why Start with a Minimal Qwen Call
When integrating a new API aggregator, the first goal is to verify that your requests reach the intended model. A minimal call to Qwen—one with a single user message and no optional parameters—isolates routing behavior from prompt complexity. If the call succeeds and the response clearly comes from Qwen, you have a working foundation for more advanced use.
Prerequisites
Before you begin, ensure you have:
- An API key from the aggregator (obtained after topping up with USDC on Base).
- The base URL for the aggregator's API (check the docs for the exact endpoint).
- A tool to send HTTP requests, such as
curl, or an SDK like OpenAI's Python library configured to use the aggregator's base URL.
The aggregator uses a unified interface compatible with the OpenAI Chat Completions format, so you can use familiar tooling.
Constructing the Smallest Request
The minimal request consists of a model identifier and a messages array with one user message. For Qwen, use the model alias provided in the aggregator's documentation—often something like qwen-max or qwen-plus. The alias maps to the correct Qwen backend.
Here is the JSON payload:
{
"model": "qwen-max",
"messages": [
{"role": "user", "content": "Hello, which model are you?"}
]
}
Keep the content simple; the goal is to elicit a response, not to test capabilities. The messages array must contain at least one message, and the role should be user for the first turn.
Sending the Request
Using curl, send a POST request to the chat completions endpoint:
curl https://api.aggregator.example/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "qwen-max",
"messages": [{"role": "user", "content": "Hello, which model are you?"}]
}'
Replace the URL and model alias with the actual values from the aggregator's documentation. If you use Python, you can set the base_url in the OpenAI client to the aggregator's endpoint and call client.chat.completions.create with the same parameters.
Reading the Response to Confirm Routing
A successful response returns a JSON object. The key fields to inspect are:
model: Should match the Qwen alias you requested (e.g.,qwen-max). If it differs, the request may have been routed to a different model.choices[0].message.content: The assistant's reply. Qwen often identifies itself if asked.id: A unique identifier for the completion; its format may hint at the backend.usage: Token counts for prompt and completion, which should be non-zero.
If the model field echoes your requested alias and the content is a coherent reply, routing worked. Some aggregators include additional metadata in headers or a system_fingerprint field; check those if available.
Common Pitfalls
- Incorrect model alias: Using a wrong alias may result in a fallback to a default model. Always verify the alias in the docs.
- Missing authentication: Without a valid API key, you'll receive a 401 error.
- Malformed messages array: Ensure it is an array of objects with
roleandcontent.
Next Steps
Once the minimal call succeeds, you can expand your requests with system messages, multiple turns, and parameters like temperature or max_tokens. Remember that pricing is official Qwen price × 1.3, and contributors can earn credits. This minimal test confirms your setup is ready for more complex interactions.