Documentation

This service provides OpenAI-compatible access to selected Qwen-family models. Use your service base URL and API key from the dashboard. In most OpenAI-compatible tools, setup comes down to three values: base URL, API key, and model name.

Base URL

https://qwenapigateway.com/v1

Authentication

Create an API key in Dashboard API keys, then send it as a bearer token.

Authorization: Bearer qgw_sk_live_xxx

Quick start

from openai import OpenAI

client = OpenAI(
    api_key="qgw_sk_live_xxx",
    base_url="https://qwenapigateway.com/v1",
)

response = client.chat.completions.create(
    model="qwen3.8-flash",
    messages=[{"role": "user", "content": "Hello"}],
)

print(response.choices[0].message.content)

Concrete usage examples

Use these settings anywhere a tool asks for an OpenAI-compatible provider. Keep the key private and create a separate gateway key for each tool so you can rotate one integration without breaking the others.

Base URL: https://qwenapigateway.com/v1
API key: qgw_sk_live_xxx
Model: qwen3.8-flash

Cursor

  • Open Cursor Settings, then Models.
  • Enable OpenAI API Key and paste your gateway key.
  • Enable Override OpenAI Base URL and enter https://qwenapigateway.com/v1.
  • Add a custom model such as qwen3.8-flash or qwen3.8-27b.

Cline and AI coding agents

  • Choose OpenAI Compatible as the provider when available.
  • Set Base URL to https://qwenapigateway.com/v1.
  • Set API Key to your gateway key.
  • Set Model ID to a gateway model name, for example qwen3.8-flash.

OpenClaw

  • Use an OpenAI-compatible custom provider.
  • Set the provider base URL to https://qwenapigateway.com/v1.
  • Store the gateway key in OpenClaw secrets or an environment variable.
  • Restart the agent after changing model configuration.

Hermes Agent

  • Configure the main model as an OpenAI-compatible endpoint.
  • Set model.base_url to https://qwenapigateway.com/v1.
  • Set the API key to your gateway key.
  • Use a supported model name such as qwen3.8-flash.

Environment variable pattern

OPENAI_API_KEY=qgw_sk_live_xxx
OPENAI_BASE_URL=https://qwenapigateway.com/v1
OPENAI_MODEL=qwen3.8-flash

For related setup patterns, see Alibaba Cloud's guides for Cursor, Cline, and OpenAI-compatible Qwen API calls. Use this gateway's base URL and API key in place of the Alibaba Cloud endpoint and key.

Supported endpoints

GET /v1/models
POST /v1/chat/completions

Model and parameter details

Requests use a standard chat-completions shape. Supported models, context limits, and public prices are listed on the Pricing page. For complete request and response examples across the wider Qwen ecosystem, see the official Qwen API reference and the OpenAI-compatible Qwen guide.

Usage and billing notes

Usage is metered by input, explicit cache creation, explicit cache reads, implicit cache reads, and output tokens. Public prices are shown on the Pricing page and charges are applied against your account balance.

Errors

Errors use the standard OpenAI error format, so SDKs raise them as normal exceptions. Every error message says what went wrong and what to do next. The most common cases:

  • API key missing or invalid — check that you copied the whole key and that it hasn't been revoked.
  • Balance empty or too low — add credit, or set a lower max_tokens.
  • Model doesn't exist — check the spelling; the error lists every available model.
  • Request too long for the model — shorten the input or lower max_tokens; the error suggests models with a longer context.
  • Request body larger than 5 MB — send less text per request.
  • Too many requests — wait a moment before retrying.
  • Request rejected by the model — for example, flagged content; the error includes the reason.
  • Model temporarily unavailable — retry after a few seconds.

Streaming

Streaming responses use Server-Sent Events. The gateway requests final usage from the model provider so your account is billed from the provider's final token report, not from partial streamed text.

Python streaming

from openai import OpenAI

client = OpenAI(
    api_key="qgw_sk_live_xxx",
    base_url="https://qwenapigateway.com/v1",
)

stream = client.chat.completions.create(
    model="qwen3.8-flash",
    messages=[{"role": "user", "content": "Write a short greeting"}],
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in stream:
    if chunk.choices:
        print(chunk.choices[0].delta.content or "", end="", flush=True)
    elif chunk.usage:
        print(f"\nTotal tokens: {chunk.usage.total_tokens}")

curl streaming

curl --no-buffer https://qwenapigateway.com/v1/chat/completions \
  -H "Authorization: Bearer qgw_sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-flash",
    "messages": [{"role": "user", "content": "Write a short greeting"}],
    "stream": true,
    "stream_options": {"include_usage": true}
  }'