好文集ChatGPT Plus¥119

Gemini 4 Carbon: Developer Guide

文章目录

Today, we are making Gemini 4 Carbon available to developers, enterprises, scientists, and consumers. First announced two weeks ago and released to cybersecurity defenders via our Fairwind Program, you can now start building using the paid tier of the Gemini API in Google AI Studio and for Google AI Ultra subscribers in AI Studio and Google Antigravity.

Gemini 4 Carbon is built to explore thoroughly, reason deeply, and run extended verification loops across sustained agentic workflows. From multi-step software engineering and full-stack web apps to open-ended questions, scientific discovery, and root-cause vulnerability patching, Carbon brings more intelligence to deeply complex tasks from start to finish.

Gemini 4 Carbon model overview

ModelModel IDDefault ThinkingPricing (per 1M tokens)
Gemini 4 Carbongemini-4-carbonmediumIntro (through Nov 30): $2 input · $10 output (95% off cached) From Dec 1: $4 input · $20 output

In this guide, we cover how to choose between Gemini 4 Carbon and Gemini 4 Argon, what is new in the API, and practical tips for building with Carbon. For more on how Gemini 4 Carbon is being used across software engineering, finance, legal, cybersecurity, and scientific research, check out our announcement blog post.

Choosing between Gemini 4 Carbon and Gemini 4 Argon

Gemini 4 Carbon joins Gemini 4 Argon in our family of frontier models, at the same introductory token price ($2 input and $10 output per 1M tokens through November 30, 2026; $4 input and $20 output starting December 1, with 95% off cached input tokens). Both models share the same unified 1M-token context window via the Gemini API, thinking_level controls, and built-in tool support, so switching or routing between them is a single model string change.

  • Reach for Gemini 4 Carbon (gemini-4-carbon) when your task tests the limits of frontier intelligence: Carbon is our strongest model and spends more thinking tokens exploring large codebases thoroughly, reasoning deeply across dense multimodal files, isolating subtle root causes, and running extended build-and-verify loops. Choose Carbon for your hardest multi-step software engineering, architectural design and code auditing, formal math and scientific discovery, high-precision financial or legal synthesis, and vulnerability research.

  • Reach for Gemini 4 Argon (gemini-4-argon) for the majority of software engineering and knowledge work: Argon remains an ideal choice for most advanced software engineering and knowledge work tasks. It provides strong frontier reasoning with tighter token usage and faster turnaround on interactive coding, day-to-day feature work, and fast production loops.

  • Pair them in multi-agent workflows: Assign gemini-4-carbon to roles that benefit most from deep reasoning, such as upfront architecture, task coordination, and final verification (including in Google Antigravity’s /swarm preview), while delegating parallel implementation slices to gemini-4-argon or gemini-3.8-flash.

For more details on which model to use when, see Compare Gemini models

What Gemini 4 Carbon unlocks across developer workflows

Gemini 4 Carbon delivers frontier performance across sustained, multi-step workflows that demand deep reasoning, thorough exploration, and rigorous verification.

  1. Long-horizon engineering, formal verification, and security tasks: Hand Carbon a complex target - like isolating root causes across a large codebase, translating security properties into formal mathematical proofs, or tracing multi-hop software flaws and generating verified patches - and let it test hypotheses against compiler and test output until every check passes.

  2. High-precision multimodal knowledge work and scientific reasoning: Point Carbon at dense repositories mixing PDFs, long videos, financial ledgers, or experimental lab data. Carbon combines exhaustive retrieval with strict schema adherence to produce grounded spreadsheets, presentations, reports, and multi-step scientific derivations.

  3. Full-stack web apps, 3D environments, and physics simulations: Carbon runs disciplined build-and-verify loops across both code and rendered UI, combining frontend design taste with strong spatial reasoning across Three.js, Blender, and WebGPU to build feature-complete apps, 3D reconstructions, and simulations. Check out our companion guide, Building 3D Games and Procedural Worlds, for practical workflows.

What’s new in the API

Before diving into workflow tips, here are the key API updates to know when calling gemini-4-carbon via the Gemini API:

Controlling reasoning depth with thinking_level

Gemini 4 Carbon uses thinking_level ("low" | "medium" | "high") to control how much reasoning (thinking) the model does before responding:

  • "high": Maximizes reasoning depth for multi-file root-cause debugging, security vulnerability patching, formal math, and upfront architecture design.

  • "medium" (default): Recommended when you want an optimal balance of speed, cost efficiency, and high first-pass accuracy across interactive coding and agentic tool use.

  • "low": Minimizes latency and cost for high-speed classification, routing, and targeted extraction.

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-4-carbon",
    input=(
        "Build a single-file HTML drum machine and synth using the "
        "Web Audio API with a 16-step sequencer, tempo slider, and "
        "a live waveform visualizer."
    ),
    generation_config={
        "thinking_level": "medium"  # "low" | "medium" (default) | "high"
    },
)
print(interaction.output_text)

Unified 1M input-output token limit and long decodes

Earlier Gemini models capped max output (thinking + response) at 64K tokens. In Gemini 4 Carbon (and Argon), input, thinking, and output share a unified 1M-token window in the Gemini API, and you can use long decode to generate past 64K tokens (up to 1M tokens minus your input) so Carbon can think as long as needed and still return complete multi-file diffs, test suites, or long-form proofs in a single pass.

  • Default output limit is 65,536 (64K) tokens: On the Interactions API, both streaming and non-streaming requests default to 65,536 tokens with no code changes required.

  • Generate up to 1M tokens with background=True: To generate past 65,536 tokens on the Interactions API, set background=True and set max_output_tokens above 65536. Set it high enough that thinking doesn't cut the answer short, and low enough to limit spend when a hard prompt uses all of it.

import time

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-4-carbon",
    input="Write a complete, rigorous proof of the prime number theorem.",
    background=True,
    generation_config={
        "max_output_tokens": 262144,
        "thinking_level": "high",
    },
)

while interaction.status in ("in_progress", "queued"):
    time.sleep(5)
    interaction = client.interactions.get(id=interaction.id)

# Each segment adds a model_output step, so join the text of all of them.
text = "".join(
    content.text
    for step in interaction.steps
    if step.type == "model_output"
    for content in step.content
    if content.type == "text"
)
print(text)
print("Status:", interaction.status)
print("Usage:", interaction.usage)

See the What's new in Gemini 4 Carbon for details on updating hardcoded 64K synchronous output limits, background retention, dynamic output clamping, and stateless continuation.

Migrating from previous models

If you are already using gemini-4-argon, switching to gemini-4-carbon is a drop-in model string change with the same thinking_level controls, 1M context window via the Gemini API, and pricing. If you are migrating from Gemini 3 or earlier models, clean up the following parameters:

  • Replace thinking_budget with thinking_level: thinking_budget is deprecated and returns a warning.

  • Remove temperature, top_p, and top_k: Custom sampling values are ignored by gemini-4-carbon and return a deprecation warning.

  • Move off explicit context caching: Remove calls that create or pass explicit cached_content. Implicit caching is enabled automatically at a 95% discount on cached input tokens.

  • Increase client timeouts: Hard reasoning prompts can take several minutes. Use background=True on the Interactions API, or set your HTTP client timeout to at least 15 to 20 minutes.

For full details, check out our migration checklist, or install the gemini-api-dev skill in your coding agent and ask it to migrate your codebase to gemini-4-carbon.

Use Gemini 4 Carbon in managed agents

You can also use gemini-4-carbon as the model for Managed Agents in the Gemini API. Managed agents provide a hosted sandbox and the Antigravity harness where Carbon's frontier reasoning can search the web, write code, verify work, and call MCP tools all with a single API call.

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-09-2026",
    agent_config={
        "type": "antigravity",
        "model": "gemini-4-carbon",
    },
    input=(
        "Audit https://web.dev for performance, Core Web Vitals, and SEO. "
        "Query Google's PageSpeed Insights API for both Mobile and Desktop strategies. "
        "Check search indexing with Google Search for site:web.dev. "
        "Format the output as a side-by-side scorecard table with prioritized fixes."
    ),
    environment="remote",
)

print(interaction.output_text)

5 practical tips for building with Gemini 4 Carbon

Here are five patterns we’ve seen our teams use to get the most out of the model and tackle their hardest problems.

1. Align on intent before long runs

Gemini 4 Carbon can work on a task independently for a long time. This means that clear alignment upfront on measurable goals and key milestones helps you get to your result most effectively. Once pointed at a clear goal, the model holds context across long runs on its own really well. To make sure a long autonomous run is pointed at the exact right target from step one:

  • Share your goal and ask Carbon to surface clarifying questions about edge cases and success criteria upfront.

  • Ideate with Carbon while scoping: Use the planning phase to pressure-test architecture and explore creative solutions. In our workflows, we’ve seen it suggest novel upgrades across the stack - from designing surprising gameplay mechanics and procedural visual effects to recommending cleaner data models and more intuitive API design.

  • Run a quick pre-flight check: Have Carbon confirm it has access to the required tools, docs, and understands the intent before starting.

  • Step back and let Carbon run to completion: Instead of prompting turn by turn, let Carbon execute the full plan autonomously - writing code, running checks, and iterating across files until it hits the target you agreed on, while pausing for your confirmation before taking irreversible steps.

2. Give the model a way to verify its work

Carbon does its best long-horizon work when it can test its own changes against a real feedback loop. Instead of making Carbon guess whether a fix worked, give it a concrete signal to check: point it at your test suite, pipe in runtime logs, let it take browser screenshots to inspect the rendered UI, or ask it to write a verification script and iterate in a loop until every check passes. Better yet, have Carbon write a reproducible verification script, record a baseline score, and test every change against that script in a loop until the target is met. With a concrete pass/fail target, Carbon can record a baseline, test hypotheses across extended verification loops, and iterate until the checks are green.

If you don’t have something to measure, ask Carbon to help analyze your project and build a baseline benchmark.

We want to fix accessibility and layout issues across our web app, but we don't have automated checks yet. First, write a headless Chrome script that crawls every route in src/routes/, inspects the live DOM and accessibility tree, and logs all violations to record our baseline score. Group the failing checks into shared root causes across our shared components, then fix them one cluster at a time. Re-run your script after each change to verify that each single fix resolves the entire cluster with zero regressions. Keep going until all routes pass with zero violations.

3. Use multimodal references and our frontend-design skill

Gemini models have long been strong at multimodal reasoning, and Gemini 4 Carbon expands what you can pass directly: images, audio, video, PDFs, code, and text. Pass reference images or architectural PDFs when building frontends and 3D reconstructions, drop in slide decks and spreadsheets for synthesis, or pass a video when recreating an animation or interaction. If you have a specific target style in mind for your project, point Carbon at 1–2 concrete visual references, or ask it to summarize your typography, color palette, and layout rules into a lightweight DESIGN.md file first so every component stays visually cohesive.

With the launch of Gemini 4 Carbon, we have also published a gemini-frontend-design skill to help you get the best frontend and UI design results out of Gemini 4 models. UIs built with this skill reliably outperform results generated without a skill or with popular third-party frontend design skills. Install it directly with npx skills add google-gemini/demolab --skill gemini-frontend-design, or browse the source in the google-gemini/demolab GitHub repository

Finally, Carbon is great at prompting other Gemini models to generate assets like images, videos, speech, or music. To make this easier, we recommend installing the Gemini API CLI alongside its agent skill (npx skills add google-gemini/gemini-skills --skill gemini-api-cli). This lets Carbon generate and save media files directly to your project folder from the terminal without writing one-off scripts or bloating its context window, so it can wire new visuals and audio straight into your build.

4. Use Carbon as an orchestrator and in multi-agent teams

For large, multi-file projects, Carbon shines at coordinating multi-agent teams - including in Google Antigravity’s new /swarm preview, which turns a single prompt into a coordinated team of agents working in isolated workspaces that you can track in real time. Assign Gemini 4 Carbon to roles demanding the deepest reasoning, such as architectural design, coordination, security auditing, and verification, while pairing it with Gemini 3.8 Flash (or Gemini 4 Argon) subagents for fast parallel implementation.

  • Pin Gemini 4 Carbon (thinking_level="medium" or "high") as the lead orchestrator and verifier to break down the architecture, define interfaces, and audit completed changes.

  • Delegate parallel implementation slices, such as migrating leaf modules, writing unit tests, or running high-frequency checks, to Gemini 3.8 Flash subagents (model: flash) for high-speed execution.

  • Orchestrate specialized models across modalities: Let Carbon coordinate Nano Banana 2.1 for product imagery, textures, and 3D reference sheets, Gemini Omni 1.2 Flash for video references, and Gemini 3.8 Flash TTS or Lyria for voice and music.

5. Have Carbon reflect on past work

At the end of a complex task - or mid-session when tackling a particularly gnarly problem - ask Carbon to step back and review the trajectory so far. Because Carbon excels at synthesizing details across long histories, building a habit of reflection pays off in two ways:

  • Skip repeated trial-and-error on codebase quirks: Every repo has non-obvious gotchas - custom test flags, strict lint rules, or deprecated helpers - that can cost extra turns to diagnose. Having Carbon write those lessons into AGENTS.md or a reusable skill means future sessions take the direct path on the first try

  • Turn one-off debugging into reusable team skills: Once Carbon figures out a reliable multi-step workflow (like running a tricky local migration or verifying a build), ask it to package those exact steps into a reusable skill so you - and your teammates - never have to rediscover them from scratch.

Try prompting Carbon with:

Investigate our current session to see where things stalled or required extra steps, and analyze why. Propose updates to our AGENTS.md or custom skills so we can improve our flow and take a more direct path next time.

When Carbon completes a long autonomous run across dozens of files, reading the raw diff isn't always the fastest way to build a mental model of what changed. Try asking Carbon to generate an interactive visual explainer of its solution - like a live architecture diagram, a data-flow map, or a step-by-step pipeline walkthrough. It’s a fast way to sanity-check the design before merging, get up to speed on unfamiliar math or rendering logic, or see the progress on your 3D render in a satisfying animation so you can understand which changes had the biggest impact.

Getting started

You can start building with Gemini 4 Carbon today across Google’s developer platforms:

Written by Geneviève Huskens & Jack Wotherspoon

全文完
查看原文

沿着这个主题继续读

从一篇文章,找到相关的教程、经验和阅读路径。

Gemini 与 Google AIGemini 入门与进阶:Gemini 4 Argon、Gemini Notebook、Antigravity 与 Flow 的用法和实测。