出海数字营销宝典 Logo
出海数字营销宝典evaoo.com
Back to AI Agent Best Practices Portal

Gemini 4 Carbon Official Developer Guide: Unified 1M Token Window, Long Decode, Managed Agents & 5 Agentic Patterns

Author: Google for Developers @googledevs (Geneviève Huskens & Jack Wotherspoon)Course Article8 min
OFFICIAL DEVELOPER GUIDE · GEMINI 4 CARBON (@GOOGLEDEVS)

Gemini 4 Carbon Developer Guide: Unified 1M Window, Long Decode, Managed Agents & 5 Agentic Patterns

Official guide by Geneviève Huskens & Jack Wotherspoon (@googledevs): $2/$10 introductory pricing (95% off cached input), Carbon vs. Argon routing, background=True long decode up to 1M tokens, Gemini 3 migration cleanup, Antigravity Managed Agents, and 5 battle-tested agentic patterns.

Author: Google for Developers (@googledevs · Geneviève Huskens & Jack Wotherspoon)·Edition: English Architecture & Prompt Playbook
Gemini 4 Carbon Developer Guide: Unified 1M Window, Long Decode, Managed Agents & 5 Agentic Patterns
Figure 1: Gemini 4 Carbon Developer Guide: Unified 1M Window, Long Decode, Managed Agents & 5 Agentic Patterns — Visual Architecture Overview16:9 WIDESCREEN EDITION

1. Model Positioning, Introductory Pricing & Unified 1M Token Window

Gemini 4 Carbon (model string: gemini-4-carbon) is Google's flagship reasoning model built to explore thoroughly, reason deeply, and run extended verification loops across sustained agentic workflows. During the introductory period through November 30, Carbon is priced at $2 input / $10 output per million tokens (standard pricing from December 1: $4 / $20), with 95% off cached input tokens across the entire 1M context window and no long-context surcharge.

Unlike earlier models with separate input and output caps, Gemini 4 shares a single unified 1M token window across input, thinking, and output tokens. Set max_output_tokens up to 65,536 for standard synchronous calls, or pass background=True via the Interactions API to run server-side long decode beyond 64K up to the remaining 1M window.

  • Carbon vs. Argon Routing: Use Gemini 4 Carbon for sustained multi-step plans, architectural refactors, and swarm orchestration; pair it with Gemini 4 Argon ($0.50 / $3.00 per 1M) for high-volume sub-agents, triage, and latency-sensitive workloads.
  • Gemini 3 Migration Cleanup: Remove fixed temperature overrides (keep default 1.0), migrate thinking_budget to thinking_level ("low" | "medium" | "high", omitting "minimal"), drop CUSTOM_TOOLS modevariants, and remove legacy prompt scaffolding that forced step-by-step plans or restricted parallel tool calls.

2. Antigravity Managed Agents & 5 Battle-Tested Agentic Patterns

Available in research preview via the Interactions API, Antigravity Managed Agents (agent="antigravity-preview-09-2026") run Gemini 4 Carbon inside a Google-managed sandbox with shell, filesystem, Python, Node.js, Playwright, outbound HTTP, and MCP support—no custom tool loop required.

Across internal benchmarks, five patterns consistently delivered the highest reliability: (1) Pair Carbon as coordinator with Argon sub-agents; (2) Specify clear boundaries and verifiable "done" criteria while letting the model explore; (3) Keep prompts concise and strip conflicting Gemini 3 workarounds; (4) Encourage targeted proactive action without escalating permissions; and (5) Enforce explicit runtime verification (unit tests, Playwright UI checks) before declaring completion.

Interactions API: Long Decode (>64K) & Antigravity Managed Agent
from google import genai

client = genai.Client()

# 1. Antigravity Managed Agent in a Google-managed sandbox
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)

# 2. Recommended Prompt Pattern: Proactive Execution + Runtime Verification
# "Take initiative on natural next steps (running tests to verify your changes,
# fixing an obvious adjacent bug you just uncovered) without expanding into
# broader refactors or escalating permissions. Before finishing, verify your
# solution against the requirements using unit tests or runtime checks."

Engineering Comparison Matrix: Anti-Patterns vs. Production Best Practices

DimensionCommon Anti-Pattern2026 Production Standard
Context & Output WindowGemini 3: Separate 64K output cap and long-context pricing cliff above 200K tokensGemini 4 Carbon: Unified 1M input+thinking+output window, flat pricing, 95% off cached input, background=True long decode
Sampling & Thinking ConfigPinning temperature=0.2, using legacy thinking_budget or CUSTOM_TOOLS modevariantsKeep default temperature=1.0 and control reasoning depth with thinking_level ("low" | "medium" | "high")

Pre-Flight Production Verification Checklist

  • 01Install the official developer skill via npx skills add google-gemini/gemini-skills --skill gemini-api-dev.
  • 02Enable background=True in the Interactions API whenever max_output_tokens exceeds 65,536.
  • 03Click "Switch to Full Bilingual Guide & Cost/Migration Workbench" above to explore all 3 Python SDK snippets, pricing calculator, and full section-by-section breakdown.

Found this actionable? Copy standard citation & summary

Formatted with canonical attribution link and executive summary—ready for Slack, Notion, or LLM context.