# MiniMax M4, GLM-5.4, and Qwen4 are in AI Gateway, from $0.06 per 1M tokens

> Each runs on your ngrok credits with a 1M-token context window, and the smallest, Qwen4-35B-A3B, solved our cache bug for about a fifteenth of what GLM-5.4 cost.

- Date: 2026-12-04
- Shipped by: Nijiko Yonskai and Brenden Ehlers
- Products: AI Gateway
- URL: https://ngrok.com/changelog/ai-gateway-minimax-m4-glm-5-4-qwen4

Four models went live in AI Gateway this week: MiniMax M4, Z.ai's GLM-5.4, Qwen4-Max, and Qwen4-35B-A3B, an open-weight model that uses about 3B of its 35B parameters per token. Each has a 1M-token context window. Pay with ngrok credits, or attach your own provider key.

| ID                   | Through          | Input / output per 1M tokens          |
| -------------------- | ---------------- | ------------------------------------- |
| `minimax/minimax-m4` | MiniMax, LLM API | $0.80 / $3.10                         |
| `z-ai/glm-5.4`       | TokenHub         | $1.40 / $4.40                         |
| `qwen/qwen4-max`     | QwenCloud        | $1.50 / $4.50                         |
| `qwen/qwen4-35b-a3b` | QwenCloud, Morph | $0.06 / $0.48 ($0.36 output on Morph) |

![AI Gateway Models page in dark mode, filtered to minimax-m4 OR glm-5.4 OR qwen4, showing minimax/minimax-m4 at $0.80 per million input tokens and $3.10 per million output tokens, qwen/qwen4-35b-a3b at $0.06 and from $0.36, qwen/qwen4-max at $1.50 and $4.50, and z-ai/glm-5.4 at $1.40 and $4.40, all built-in with 1M context windows.](https://ngrok.com/blog-assets/images/2026-12-04-ai-gateway-minimax-m4-glm-5-4-qwen4/new-models-dark.png)

MiniMax M4, GLM-5.4, and Qwen4-Max read images and video. Qwen4-Max and Qwen4-35B-A3B on QwenCloud can also cache a long prompt for an hour: mark the content block with `"cache_control": { "type": "ephemeral", "ttl": "1h" }`. On Qwen4-Max, that write costs $3.00 per 1M tokens, and each read costs $0.075. QwenCloud's [cache guide](https://docs.qwencloud.com/developer-guides/run-and-scale/explicit-cache-qwen4) has the rest.

We gave all four models the cache bug below, five times each. Every run found both bugs. Qwen4-35B-A3B did it for $0.00017 to $0.00028 an answer. GLM-5.4 charged about 15 times as much for the same answer. Start small.

## Get started

<Steps>
<Step title="Get an access key">

[Sign in or create an account](https://app.ngrok.ai/), then create an [**access key**](https://app.ngrok.ai/keys) that allows these models. Use credits, or [attach your own provider key](https://ngrok.com/docs/ai-gateway/guides/attaching-provider-keys).

</Step>
<Step title="Set up the project">

In an ES module project (`"type": "module"` in `package.json`), install the OpenAI SDK and save your key in `.env.local`:

```bash
npm install openai && npm install --save-dev tsx
echo "AI_GATEWAY_API_KEY=your_access_key_here" > .env.local
```

</Step>
<Step title="Ask about the bug">

Save this as `index.ts`:

```typescript
import OpenAI from "openai";

const client = new OpenAI({
	baseURL: "https://gateway.ngrok.ai/v1",
	apiKey: process.env.AI_GATEWAY_API_KEY,
});

const cache = `
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const cache = new Map();
let calls = 0;

async function fetchUser(id) {
  calls += 1;
  await sleep(50);
  return id === 2 ? null : { id };
}

async function getUser(id) {
  const hit = cache.get(id);
  if (hit) return hit;
  const user = await fetchUser(id);
  cache.set(id, user);
  return user;
}

await Promise.all([1, 1, 2, 1, 2, 3].map(getUser));
await getUser(2);
await getUser(2);
await getUser(1);
console.log(calls);`;

const response = await client.chat.completions.create({
	model: "qwencloud:qwen/qwen4-35b-a3b",
	messages: [
		{
			role: "user",
			content: `How many times does this script call fetchUser? Put only the number on the first line, then explain in one sentence.\n${cache}`,
		},
	],
});

console.log(response.choices[0]?.message.content);
```

</Step>
<Step title="Run it">

```bash
node --env-file=.env.local --import tsx index.ts
```

The answer is 8, not 3. All six concurrent calls miss the empty cache, and a cached `null` reads as a miss. Wording varies between runs.

</Step>
<Step title="Check Activity">

Open [**Activity**](https://app.ngrok.ai/activity) to see the request's provider, tokens, and cost. Swap `model` for `minimax/minimax-m4`, `z-ai/glm-5.4`, or `qwen/qwen4-max` to compare.

</Step>
</Steps>
