Qwen

Call the Qwen 3.8 and 3.7 models through HopBase's OpenAI-compatible Chat Completions API.

Qwen runs over HopBase's OpenAI-compatible protocol. Use https://api.hop-base.com/v1 with Authorization: Bearer sk-your-key, and take the exact model ID from GET /v1/models.

Models

Model IDContextImage and video input
qwen3.8-max1MYes
qwen3.8-flash1MYes
qwen3.7-max1MText only
qwen3.7-plus1MYes
qwen3.7-flash1MYes

All five expose a 1,048,576-token context window, with up to 991,808 input tokens and 131,072 output tokens per request. All five sit in the same plan group, so one key reaches all of them.

Endpoint

POST /v1/chat/completions is the supported entry point. Streaming works normally.

Ask for usage explicitly when streaming

Send stream_options: { "include_usage": true } if your client needs to read token usage from a streamed response. Billing is accurate either way, but without that flag the usage chunk is not delivered to the client.

Qwen-specific request fields such as enable_thinking, thinking_budget, and enable_search are passed through to the model unchanged — HopBase neither requires nor validates them. Function calling and JSON mode work as they do on the official API.

What the gateway changes in your request

Two rewrites are worth knowing about before you build a long-running agent on Qwen.

BehaviorEffect on your request
Message-history guardOn chat/completions, a request with more than 26 messages keeps at most the first 2 system / developer messages plus the last 24 messages. Everything in between is dropped
previous_response_idRemoved if present. Requests are balanced across accounts, so an ID issued by one is not valid on another

The history guard applies even to 1M-context models

A long multi-turn conversation is truncated by message count, not by token count. If your agent depends on the full history, compress it into fewer messages yourself, and keep anything that must survive in the first two system messages.

Long input requests

Some Qwen models change tier once a request's input crosses a length threshold.

  • The threshold counts the whole prompt — cached input plus non-cached input.
  • Crossing it moves the entire request to that tier, not only the tokens past the threshold.
  • Prompt caching does not keep you under the threshold. Caching changes which rate applies to the cached portion; it does not shrink the prompt for tier purposes. The only way to stay under is to send a shorter prompt.

Which models have tiers, and where the thresholds sit, is shown in the signed-in model catalog.

Reading usage

completion_tokens already includes reasoning tokens, so do not add them again. completion_tokens_details.reasoning_tokens is a subset of the output, reported for visibility only.

Your HopBase usage record and the response body count input differently, which matters when you reconcile:

FieldMeaning
Response prompt_tokensWhole prompt, cached portion included
Usage record Input tokensPrompt minus the cached portion
Usage record Cached input tokensThe cached portion, listed separately

So the usage record's input plus cached input equals the response's prompt_tokens.

curl

curl https://api.hop-base.com/v1/chat/completions \
  -H "Authorization: Bearer sk-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-max",
    "messages": [{ "role": "user", "content": "Summarize this quarter'\''s risks in five bullets." }]
  }'

Error handling

Upstream 4xx responses are passed through with vendor-specific error-code prefixes stripped, so the message text is human-readable but not stable. Branch on the HTTP status and the code field, never on the message string.

A model name that is not in your group returns 404 model_not_found. Model IDs are exact — read them from GET /v1/models rather than guessing.

Group

Qwen has its own plan group. A Qwen key does not reach other families, and a key from another family does not reach Qwen. This includes the Wan 3.0 and HappyHorse video models, which are a separate group with a separate key even though both come from the same vendor.

On this page