Skip to main content

Gemini 4 Carbon is in AI Gateway, with a dial for how much it ponders

Gemini 4 Carbon, Google’s model for hard debugging, deep analysis, and long agent runs, is now in AI Gateway as google/gemini-4-carbon. Pay with your ngrok credits, or attach your own Google key and let Google bill you.

Google launched Carbon at an introductory price that ends on November 30. On December 1, every rate doubles:

Per 1M tokensThrough Nov 30, 2026From Dec 1, 2026
Input$2.00$4.00
Output, including thinking$10.00$20.00
Cached input$0.10$0.20

AI Gateway switches to the new rates at 00:00 UTC on December 1. Grounding with Google Search costs $14 per 1,000 queries at both prices. Google’s pricing page lists both sets of rates.

Carbon has a 1,048,576-token context window that input, thinking, and output share. Through AI Gateway, Carbon:

  • Returns up to 65,536 tokens per response. The gateway doesn’t accept background requests, which Google’s long decode uses to go further.
  • Reads text, images, audio, and PDFs, and bills images and audio at the text input rate.
  • Doesn’t accept video input on ngrok credits.
  • Caches repeated prompt prefixes on its own and bills them at the cached input rate. It doesn’t support explicit caches.

Thinking level is your cost dial

You can’t turn Carbon’s thinking off, but you pick how hard it thinks. Set reasoning_effort to low, medium, or high, and Google maps it to the Carbon thinking level with the same name. Leave it out, and Carbon thinks at medium. Thinking tokens bill as output, so the level sets what an answer costs.

Say your rate limiter is generous once and stingy forever: a client gets its burst of 20 requests, then never another token. The limiter resets its clock on every call, so a client that calls more often than every 100 ms never earns a token back. We showed Carbon that limiter, from the example below, five times at each level. It found the bug and answered 0% in all 15 runs. Only the bill changed:

Thinking levelThinking tokensCost per answer
low0$0.0011 – $0.0012
medium222 – 485$0.0033 – $0.0060
high2,723 – 3,545$0.028 – $0.037

Those costs use the introductory price, so double them from December 1. At high, the same answer cost about 28 times as much as at low, on average. Start low, and raise the level when a task needs it. This bug is small enough that Gemini 3.8 Flash (google/gemini-3.8-flash), at $0.75 input and $3.75 output per 1M tokens, found it in 5 of 5 runs too. Save Carbon for the problems a cheaper model gets wrong.

max_completion_tokens caps thinking and the answer together, so a low cap can cut an answer off. If you set one, Google suggests at least 32,768. Carbon ignores temperature, top_p, and top_k, so drop them from your requests.

Get started

Carbon accepts OpenAI chat completions, Gemini GenerateContent, and Gemini Interactions requests. These steps use chat completions and the OpenAI SDK, where reasoning_effort sets the thinking level. The Google provider docs cover the Gemini formats. To try Carbon before you write code, show it the limiter in the playground.

  1. Get an access key

    Create an ngrok account or sign in. Create an access key that allows Google and Gemini 4 Carbon. Confirm your account has credits, or attach your own Google key.

  2. Install the OpenAI SDK

    The setup guide shows the same steps when you select OpenAI and TypeScript. Install the OpenAI SDK and TypeScript runner:

    npm install openai && npm install --save-dev tsx
  3. Save your access key

    Save your ngrok access key in .env.local. Keep this file out of version control:

    AI_GATEWAY_API_KEY=your_access_key_here
  4. Save the example

    Use an ES module project ("type": "module" in package.json) for top-level await. Save this example 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 limiter = `class TokenBucket {	tokens = 20;	last = Date.now(); 	take() {		const now = Date.now();		const refill = Math.floor(((now - this.last) * 10) / 1000);		this.tokens = Math.min(20, this.tokens + refill);		this.last = now;		if (this.tokens < 1) return false;		this.tokens -= 1;		return true;	}}`; const response = await client.chat.completions.create({	model: "google/gemini-4-carbon",	reasoning_effort: "low",	messages: [		{			role: "user",			content: `This limiter should allow 10 requests per second with a burst of 20. A client calls take() every 20 ms. From the second minute on, what percentage of calls succeed? Answer with the percentage and one sentence.\n${limiter}`,		},	],}); console.log(response.choices[0]?.message.content); const usage = response.usage;if (usage) {	console.log("Thinking tokens:", usage.total_tokens - usage.prompt_tokens - usage.completion_tokens);}
  5. Run it

    Run the example from your project directory:

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

    It prints the percentage, a one-sentence explanation, and the thinking token count. One run at low printed:

    0%Because `this.last` is unconditionally updated on every 20 ms call, `refill` always evaluates to `Math.floor(0.2)` (which is 0), preventing any new tokens from ever being added once the initial 20 tokens are exhausted in the first second.Thinking tokens: 0

    The wording varies between runs. The answer is in choices[0].message.content. For Carbon, the chat completions response counts thinking tokens in usage.total_tokens but not in completion_tokens, so the example subtracts the prompt and completion tokens from the total. The OpenAI SDK guide covers the rest of the SDK.

  6. Check the request in Activity

    Open Activity, find the request, and inspect its model, provider, status, token usage, and cost. Then set reasoning_effort to "high", run the example again, and compare the two costs.