Skip to main content

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

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.

IDThroughInput / output per 1M tokens
minimax/minimax-m4MiniMax, LLM API$0.80 / $3.10
z-ai/glm-5.4TokenHub$1.40 / $4.40
qwen/qwen4-maxQwenCloud$1.50 / $4.50
qwen/qwen4-35b-a3bQwenCloud, Morph$0.06 / $0.48 ($0.36 output on Morph)

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 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

  1. Get an access key

    Sign in or create an account, then create an access key that allows these models. Use credits, or attach your own provider key.

  2. 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:

    npm install openai && npm install --save-dev tsx
    echo "AI_GATEWAY_API_KEY=your_access_key_here" > .env.local
  3. Ask about the bug

    Save this as index.ts:

    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);
  4. Run it

    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.

  5. Check Activity

    Open 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.