API for Qwen: connecting Qwen 3.8 Max, pricing and Python examples
Connect qwen3.8-max through the OpenAI SDK, send images, feed a long document and calculate the price of a typical request by formula.
4 min · · models · API keys
If you need an API for Qwen, the shortest path looks like this: a key from the dashboard, the OpenAI SDK and the qwen3.8-max model. A separate account with the maker's cloud and a special SDK are not required: the request format is the same as chat.completions. Below are the connection, examples with images and a long context, and a price calculation.
What qwen3.8-max is in our table
Figures as of 18 October 2026 (prices in dollars per 1M tokens):
| Parameter | qwen3.8-max | qwen3.8-flash |
|---|---|---|
| Input / output | 0.088 / 0.238 | 0.038 / 0.075 |
| Cache read | 0.088 | 0.038 |
| Context | 1M | 1M |
| Image input | yes | no |
| Strength index | 45 | 40 |
The strength index is the Intelligence Index from Artificial Analysis; we give no other quality figures. Test whether a model fits your task on your own data. For comparison: the official prices for qwen3.8-max in our table are 2 / 6. The current list of models and prices: GET https://api.zukko.pro/v1/models or the "Models" page in the dashboard.
How to get a Qwen API key
People often ask about a "qwen ai api key". Here it is a single gateway key of the form fetch_... that works for all models, not only Qwen.
- Open the dashboard and top up the balance (from $1: SBP, cryptocurrency or MasterCard cards).
- In the API keys section, create a key. The full key is shown once.
- If you like, restrict it: a daily and monthly dollar limit and a list of allowed models (
allowed_models), for example onlyqwen3.8-max.
It is better to keep the key in an environment variable rather than in code.
The first request in Python
pip install openai
export ZUKKO_API_KEY=fetch_your_keyimport os
from openai import OpenAI
client = OpenAI(
base_url="https://api.zukko.pro/v1",
api_key=os.environ["ZUKKO_API_KEY"],
)
r = client.chat.completions.create(
model="qwen3.8-max",
messages=[
{"role": "system", "content": "You are an assistant. Answer briefly."},
{"role": "user", "content": "Explain request idempotency in three sentences."},
],
max_tokens=400,
)
print(r.choices[0].message.content)
print(r.usage)The trailing /v1 in the address is mandatory. More Python examples and error handling are in the Python reference.
The same request via curl
curl https://api.zukko.pro/v1/chat/completions \
-H "Authorization: Bearer $ZUKKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [{"role": "user", "content": "Hello!"}],
"max_tokens": 100
}'Streaming
stream = client.chat.completions.create(
model="qwen3.8-max",
messages=[{"role": "user", "content": "Write a short description of a delivery service"}],
stream=True,
)
for chunk in stream:
if chunk.choices:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)The if chunk.choices: check is needed because the last chunk, which carries usage data, arrives with an empty choices list.
Working with images
qwen3.8-max accepts images as input (qwen3.8-flash does not). An image can be passed as a data URL:
import base64
with open("receipt.jpg", "rb") as f:
b64 = base64.b64encode(f.read()).decode("ascii")
r = client.chat.completions.create(
model="qwen3.8-max",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "List the receipt items and the total as JSON."},
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64}"}},
],
}],
max_tokens=600,
)
print(r.choices[0].message.content)How many tokens an image takes depends on its size, so look at the usage field and measure on several files. Oversized images may return 413: shrink them before sending. More on recognition in the post on receipts and screenshots.
Long context
The stated context of the model in the table is 1M tokens. That does not mean every request should be huge: input is paid each time. If you put 500,000 tokens into a request (a large contract or a chunk of a codebase) and get a 2000-token answer:
500,000 × 0.088 / 1,000,000 = $0.044 2000 × 0.238 / 1,000,000 = $0.000476 Total about $0.0445.
At the official prices from our table (2 / 6) the same request looks like this: 500,000 × 2 / 1,000,000 = $1.00 and 2000 × 6 / 1,000,000 = $0.012, total $1.012. That is enough for comparing orders of magnitude. But always remember that with repeated questions on one document the input is paid again, and for qwen3.8-max the cache read price (0.088) equals the input price, so the cache gives no discount. Long contexts in general are covered in the post on the million-token context window.
The price of a typical request
Suppose 3000 input tokens (a question and a text fragment) and 600 output tokens:
3000 × 0.088 / 1,000,000 = $0.000264 600 × 0.238 / 1,000,000 = $0.0001428 Total $0.0004068, about $0.0004.
A thousand such requests cost about $0.41 (by the formula: 1000 × 0.0004068).
Which Qwen model to choose
qwen3.8-max: you need image input or a higher strength index (45 versus 40).qwen3.8-flash: mass text tasks where price matters (0.038 / 0.075). More in the post on Qwen 3.8 Flash.
Which is better for your task is shown by running 20 real examples on two models. We make no claims about quality.
Typical errors
- 401: wrong key.
- 402: not enough balance.
- 403,
model_not_allowed_for_key: this model is not allowed in the key. - 404,
model_not_found: a typo in the model name (the correct one isqwen3.8-max). - 413: the request is too large, for example an uncompressed image.
- 429: a key limit or a limit at the model provider.
- 503: the provider is unavailable or the model is disabled (
model_disabled): choose another model fromGET /v1/models.
Always check exact model names and prices against GET /v1/models.
FAQ
Do I need a separate key from Alibaba or another cloud?
No. To call qwen3.8-max through the gateway you use a single fetch_... key from the dashboard.
Does qwen3.8-max support images?
Yes, qwen3.8-max accepts image input. qwen3.8-flash has no image input.
How much does a thousand requests cost?
For a request of 3000 input and 600 output tokens, about $0.41 per thousand. The real figure is shown by the usage field and the "Usage" page in the dashboard.
Can I call Qwen in the Anthropic format?
Any model can be called in both the OpenAI format and the Anthropic format. For Qwen the OpenAI format with base_url ending in /v1 is usually more convenient.
zukko
Pay 25×
less
for Claude Code & ChatGPT
One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.
Related articles
- xAI Grok API: Connecting Grok 4.7, Price and the 256K ContextHow to call grok-4.7 through an OpenAI-compatible API, what to do about the 256K context limit and what typical requests cost. Plus a comparison with Grok 4.6.
- Grok API from Russia: connecting without a foreign cardStep by step connection to Grok 4.7, 4.6 and 4.5 through a gateway: key, address, first request in curl and Python, streaming, images and payment by SBP or crypto.
- Claude Sonnet 5.5 via API: connection, prices and cache at October 18, 2026How to call claude-sonnet-5-5 from Python and curl, what a typical request costs with and without cache, and how it differs from Sonnet 5 and Sonnet 4.6.
- Claude on Android in Russia: what to do if the app won't installIf the official Claude app won't install on Android in Russia, you can still use the model from your phone: through the gateway's web chat or a client with your own key.