Gemini 4 Carbon is in AI Gateway, with a dial for how much it ponders
Shipped by Nijiko Yonskai, Alice Wasko, and Brenden Ehlers
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:
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
backgroundrequests, 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:
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.
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.
Install the OpenAI SDK
The setup guide shows the same steps when you select OpenAI and TypeScript. Install the OpenAI SDK and TypeScript runner:
Save your access key
Save your ngrok access key in
.env.local. Keep this file out of version control:Save the example
Use an ES module project (
"type": "module"inpackage.json) for top-levelawait. Save this example asindex.ts:Run it
Run the example from your project directory:
It prints the percentage, a one-sentence explanation, and the thinking token count. One run at
lowprinted:The wording varies between runs. The answer is in
choices[0].message.content. For Carbon, the chat completions response counts thinking tokens inusage.total_tokensbut not incompletion_tokens, so the example subtracts the prompt and completion tokens from the total. The OpenAI SDK guide covers the rest of the SDK.Check the request in Activity
Open Activity, find the request, and inspect its model, provider, status, token usage, and cost. Then set
reasoning_effortto"high", run the example again, and compare the two costs.