> ## Documentation Index
> Fetch the complete documentation index at: https://ngrok.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Use QwenCloud with the AI Gateway

> Call QwenCloud models through the ngrok AI Gateway with ngrok.ai credits or your own QwenCloud API key, including thinking and tool calls.

[QwenCloud](https://qwencloud.com) serves the Qwen family of models, plus open models from DeepSeek, Moonshot AI, and Z.ai.

QwenCloud supports Chat Completions, Responses, and Anthropic Messages requests.

> [!NOTE]
>
> QwenCloud is a **built-in provider** you can pay for with credits, so a provider key is optional.
> Add your own QwenCloud key to bill usage to your QwenCloud account instead of your ngrok.ai credits.

## Setup

### 1. Create an access key and add credits

Follow the [quickstart](https://ngrok.com/docs/ai-gateway/quickstart.md) to create an access key and purchase [credits](https://ngrok.com/docs/ai-gateway/concepts/credits.md) in [app.ngrok.ai](https://app.ngrok.ai).

### 2. Store your QwenCloud API key (optional)

Skip this step to pay with credits.
To bring your own key, create an API key in your [QwenCloud](https://qwencloud.com) account.
Then [add a provider key](https://ngrok.com/docs/ai-gateway/guides/attaching-provider-keys.md#add-a-provider-key) and [create an access key configuration](https://ngrok.com/docs/ai-gateway/guides/access-key-configurations.md#create-a-configuration) with a `qwencloud` routing rule that uses it.

### 3. Send requests

Send requests with your access key:

```python theme={"theme":{"light":"css-variables","dark":"css-variables"}}
from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.ngrok.ai/v1",
    api_key="ng-xxxxx-g1-xxxxx",
)

response = client.chat.completions.create(
    model="qwencloud:qwen/qwen3.8-max",
    messages=[{"role": "user", "content": "Hello!"}]
)
```

For a model that other providers also serve, such as `moonshotai/kimi-k3`, add the `qwencloud:` prefix to keep the request on QwenCloud.

## Thinking and tool calls

QwenCloud's Chat Completions API differs from OpenAI's in two ways that affect requests through the gateway:

* **Thinking:** QwenCloud turns thinking on and off with its own `enable_thinking` field, and sets a token budget with `thinking_budget`.
  The gateway forwards both.
  It removes `reasoning_effort` and lists it in the `Ngrok-AIG-Removed-Params` [response header](https://ngrok.com/docs/ai-gateway/how-it-works.md#response-headers).
  Qwen3.8 Max thinks by default.
  Some models, such as `z-ai/glm-5.3` and `qwen/qwen3.8-2.4t-a95b`, always think, and QwenCloud rejects requests that set `enable_thinking` to `false`.
  The gateway also removes both fields for the Qwen3.5 Omni models, because QwenCloud refuses thinking on their audio requests.
* **Tool choice:** QwenCloud doesn't support `tool_choice: "required"`.
  While thinking is on, `tool_choice` accepts only `auto` or `none`, so turn thinking off to force a specific tool.
  The gateway forwards `tool_choice` as sent, so QwenCloud returns the error.

In the OpenAI Python SDK, send these fields in `extra_body`:

```python theme={"theme":{"light":"css-variables","dark":"css-variables"}}
response = client.chat.completions.create(
    model="qwencloud:qwen/qwen3.8-max",
    messages=[{"role": "user", "content": "Hello!"}],
    extra_body={
        "enable_thinking": True,
        "thinking_budget": 4096,
    },
)
```

See QwenCloud's [thinking](https://docs.qwencloud.com/developer-guides/text-generation/thinking) and [function calling](https://docs.qwencloud.com/developer-guides/text-generation/function-calling) guides for details.

## Available models

See the [model catalog](https://ngrok.com/docs/ai-gateway/reference/model-catalog.md#qwencloud).
The Qwen3.5 Omni models can also return audio.

## Next steps

* [Provider keys](https://ngrok.com/docs/ai-gateway/guides/attaching-provider-keys.md)
* [Access key configurations](https://ngrok.com/docs/ai-gateway/guides/access-key-configurations.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.