> ## AI Agent Context
> - Full documentation index: https://aistudio.google.com/llms.txt
> - Gemini Docs MCP server (consistent live info): https://gemini-api-docs-mcp.dev
> - Coding agent skills & setup guide: https://aistudio.google.com/docs/coding-agents.md

# What's new in Gemini 4 Carbon

Gemini 4 Carbon (`gemini-4-carbon`) is our strongest reasoning model, built for sustained agentic workflows across complex software engineering, multimodal knowledge work, scientific reasoning, and cybersecurity defense. On hard problems, Carbon spends more thinking tokens to explore hypotheses, verify its work, and check edge cases before responding.

Gemini 4 Carbon is available on the paid tier of the Gemini API and in Google AI Studio. Like [Gemini 4 Argon](/docs/whats-new-gemini-4-argon?generate-content=true), it supports a unified 1M-token context window, long decode up to 1M tokens, and tunable thinking levels (`low`, `medium`, `high`) at the same per-token price.

{% card-grid %}
  {% card description="Build and verify full-stack web and 3D apps with Gemini 4 Carbon." href="https://aistudio.google.com/apps?model=gemini-4-carbon" icon="experiment" title="Build in AI Studio" /%}

  {% card description="Read practical prompting and multi-agent patterns for Gemini 4 Carbon." href="https://aistudio.google.com/learn/gemini-4-carbon-developer-guide" icon="rocket_launch" title="Developer guide" /%}

  {% card description="View token limits, supported capabilities, and full specifications." href="/docs/models/gemini-4-carbon" icon="id_card" title="Model card" /%}

{% /card-grid %}

This guide explains what's new in Gemini 4 Carbon, how to choose between Gemini 4 models, API changes, code examples, and migration guidance.

## New model  {% id="new-model" %}

| Model | Model ID | Default thinking level | Pricing | Description |
| :--- | :--- | :---: | :--- | :--- |
| Gemini 4 Carbon | `gemini-4-carbon` | `medium` | See [Pricing](/docs/whats-new-gemini-4-carbon?generate-content=true#pricing) below. | Our strongest reasoning model, built for sustained agentic coding, multimodal knowledge work, scientific discovery, and cybersecurity defense. |

For complete details, see the [Gemini 4 Carbon model page](/docs/models/gemini-4-carbon) and [Latest Gemini models](/docs/latest-model?generate-content=true). For full pricing details, see the [pricing section](/docs/whats-new-gemini-4-carbon?generate-content=true#pricing) on this page or the [pricing page](/docs/pricing#gemini-4-carbon).

## Quickstart  {% id="quickstart" %}

Use the following example to send a request to `gemini-4-carbon` with the recommended default `thinking_level` (`medium`) and a 64K output token limit:

{% tabs %}
  {% tab label="Python" %}
  ```bash
  pip install -U "google-genai>=2.30.1"
  ```

  ```python
  from google import genai
  from google.genai import types
  
  client = genai.Client()
  
  response = client.models.generate_content(
      model="gemini-4-carbon",
      contents="Write a three.js script that renders a realistic 3D black hole with gravitational lensing.",
      config=types.GenerateContentConfig(
          max_output_tokens=65536,
          thinking_config=types.ThinkingConfig(thinking_level="medium"),
      ),
  )
  
  print(response.text)
  ```

  {% /tab %}

  {% tab label="JavaScript" %}
  ```bash
  npm install "@google/genai@>=2.29.1"
  ```

  ```javascript
  import { GoogleGenAI } from "@google/genai";
  
  const ai = new GoogleGenAI({});
  
  const response = await ai.models.generateContent({
    model: "gemini-4-carbon",
    contents: "Write a three.js script that renders a realistic 3D black hole with gravitational lensing.",
    config: {
      maxOutputTokens: 65536,
      thinkingConfig: {
        thinkingLevel: "medium",
      },
    },
  });
  
  console.log(response.text);
  ```

  {% /tab %}

  {% tab label="REST" %}
  ```bash
  curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-4-carbon:generateContent" \
    -H "x-goog-api-key: $GEMINI_API_KEY" \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
      "contents": [{
        "parts": [{"text": "Write a three.js script that renders a realistic 3D black hole with gravitational lensing."}]
      }],
      "generationConfig": {
        "maxOutputTokens": 65536,
        "thinkingConfig": {
          "thinkingLevel": "medium"
        }
      }
    }'
  ```

  {% /tab %}

{% /tabs %}

## What's new in Gemini 4 Carbon  {% id="whats-new" %}

* **Extended verification and agentic coding:** Runs deeper build-and-verify loops across complex repositories, frontend UI design, and 3D scenes, isolating root causes and checking fixes against tests.
* **Higher precision on multimodal knowledge work:** Stronger source grounding with fewer unsupported claims across dense PDFs, spreadsheets, slides, and workspace data, paired with strict adherence to output schemas.
* **Scientific and cybersecurity reasoning:** Improved performance on formal proofs, experimental data analysis, vulnerability discovery, and root-cause patching.
* **Unified 1M context window and long decode:** Input, thinking, and output tokens share one 1,048,576-token window (with a 32K per-request cap for non-streaming calls and a 64K per-stream cap for streaming calls), and long decode lets a single generation go up to 1M tokens minus your input. The latest Google GenAI SDKs continue for you by default. See [Long decode](/docs/long-decode?generate-content=true).
* **Supported in Managed Agents:** The [Antigravity agent](/docs/antigravity-agent) in Gemini Managed Agents now supports `gemini-4-carbon`.

## Choosing between Carbon, Neon, Hydrogen, and other models  {% id="choosing-between-models" %}

Gemini 4 Carbon, [Gemini 4 Neon](/docs/whats-new-gemini-4-neon?generate-content=true), and [Gemini 4 Hydrogen](/docs/whats-new-gemini-4-hydrogen?generate-content=true) share the same 1M unified context window, long decode architecture, and built-in tools:

* **Gemini 4 Carbon (`gemini-4-carbon`):** Built for tasks that push the limits of reasoning depth. Carbon spends more thinking tokens per turn to explore thoroughly and verify its work, which increases per-turn token use and latency. Use it for complex root-cause debugging, architectural design, dense multimodal synthesis, scientific proofs, and security auditing.
* **Gemini 4 Neon (`gemini-4-neon`):** Brings frontier-level intelligence with fast end-to-end task completion ($3.00 / $15.00 per 1M tokens, paid tier only) across complex software engineering, knowledge work, and science workflows.
* **Gemini 4 Hydrogen (`gemini-4-hydrogen`):** Fast and cost-efficient ($1.50 / $7.50 per 1M tokens, plus a Free tier) for everyday coding, interactive apps, multimodal documents, and parallel subagent execution.

For side-by-side comparisons and multi-model orchestration examples, see [Choosing a model](/docs/choosing-a-model) and [Latest Gemini models](/docs/latest-model?generate-content=true#compare-models).

## Understanding thinking levels  {% id="understanding-thinking-levels" %}

The [thinking level](/docs/thinking?generate-content=true) is your main control over quality, latency, and token use in Gemini 4 Carbon:

| Thinking level | Token use | When to use |
| :--- | :--- | :--- |
| `low` | Fewest tokens, lowest latency | Simpler tasks and cost-sensitive work. Also works for analysis and writing tasks that need light thinking. Quality can drop on hard tasks. |
| `medium` (default) | Balanced | Recommended for most tasks, including complex code and agentic use cases. |
| `high` | Most tokens, slowest first token | Complex reasoning, hard math and science, and the most difficult code or agent tasks. Pairs well with long decode for long outputs. |

Run your evaluations at all three levels with a high `max_output_tokens` so the limit doesn't cut answers short. Then pick the lowest `thinking_level` that meets your quality bar. To learn more, see the [thinking guide](/docs/thinking?generate-content=true).

{% tabs %}
  {% tab label="Python" %}
  ```python
  from google import genai
  from google.genai import types
  
  client = genai.Client()
  
  response = client.models.generate_content(
      model="gemini-4-carbon",
      contents="Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",
      config=types.GenerateContentConfig(
          thinking_config=types.ThinkingConfig(
              thinking_level="medium",  # Balanced reasoning effort for complex tasks
          ),
      ),
  )
  
  print(response.text)
  ```

  {% /tab %}

  {% tab label="JavaScript" %}
  ```javascript
  import { GoogleGenAI } from "@google/genai";
  
  const ai = new GoogleGenAI({});
  
  const response = await ai.models.generateContent({
    model: "gemini-4-carbon",
    contents: "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely.",
    config: {
      thinkingConfig: {
        thinkingLevel: "medium", // Balanced reasoning effort for complex tasks
      },
    },
  });
  
  console.log(response.text);
  ```

  {% /tab %}

  {% tab label="REST" %}
  ```bash
  curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-4-carbon:generateContent" \
    -H "x-goog-api-key: $GEMINI_API_KEY" \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
      "contents": [{
        "parts": [{"text": "Analyze this payment processing pipeline for race conditions during retry attempts and rewrite the transaction locks safely."}]
      }],
      "generationConfig": {
        "thinkingConfig": {
          "thinkingLevel": "medium"
        }
      }
    }'
  ```

  {% /tab %}

{% /tabs %}

## Larger output and long decode  {% id="shared-context-window" %}

When a task requires deep reasoning, Gemini 4 Carbon can think longer and work harder to finish complex math, science, and coding problems in a single generation.

* **Unified 1M-token context window:** Input, thinking, and output tokens share one 1,048,576-token window, so Carbon can use up to 1M tokens minus your input tokens for thinking and output combined.
* **Use `thinking_level` to control reasoning depth:** `thinking_level` sets how deeply the model reasons before answering. `max_output_tokens` caps your combined thinking and output tokens. The response stops once thinking plus output hits `max_output_tokens`, so set it high enough to leave room for the final answer.
* **Per-request caps (64K streaming / 32K non-streaming):** One streaming request returns up to 65,536 tokens. One non-streaming request returns up to 32,768 tokens, down from 65,536 on Gemini 3.x. For REST calls, these caps are also the defaults.

The latest Google GenAI SDKs run long decode for you by default. Use Python `google-genai` 2.30.1 or higher, or JavaScript `@google/genai` 2.29.1 or higher.

In these versions, `automatic_continuation` is `True` by default, so you do not need to set it. When you set `max_output_tokens` above the per-request cap, `generate_content` and `generate_content_stream` automatically continue across requests until the model finishes or reaches `max_output_tokens`, returning one combined response.

```python
response = client.models.generate_content(
    model="gemini-4-carbon",
    contents="Write a complete, rigorous proof of the prime number theorem.",
    config=types.GenerateContentConfig(
        max_output_tokens=262144,
        thinking_config=types.ThinkingConfig(thinking_level="high"),
        automatic_continuation=True,  # Default.
    ),
)
```

To run the loop yourself, set `automatic_continuation=False`. If you call REST or use an older SDK, requests stop at the per-request cap. For REST loops, third-party frameworks, token counting, and when to use long decode, see the [long decode guide](/docs/long-decode?generate-content=true).

{% callout type="note" %}
  On a hard task, the model can spend an entire 64K or 32K hop on thinking and return empty text with a `continuation_token`. This is normal, and the final answer arrives in later hops.

{% /callout %}

### Setting output token limits  {% id="setting-output-token-limits" %}

`max_output_tokens` sets the maximum combined thinking and output tokens for a generation, including all continuation requests. Set it high enough that thinking does not cut the answer short. Set it low enough to limit spend when a hard prompt uses all of it.

Use these values as a starting point:

* **Standard tasks:** Keep the default.
* **Existing apps with a limit lower than 32K:** Raise `max_output_tokens` to 32,768. To use fewer tokens, lower `thinking_level`.
* **Tasks that used more than 32K tokens before:** Set `max_output_tokens` to 65,536.
* **Complex reasoning and coding:** Set `max_output_tokens` to 131,072 or 262,144, up to 1,048,576 minus your input tokens.

If a request uses all of `max_output_tokens`, it returns `finish_reason: "MAX_TOKENS"` and still includes a `continuation_token`. You can resume or start again.

* **Resume from the checkpoint:** Send the original request with the latest `continuation_token` and a higher `max_output_tokens`. If you do not raise `max_output_tokens`, the request returns `400 INVALID_ARGUMENT`.
* **Start again:** Send the original request with a higher `max_output_tokens` and no `continuation_token`.

## Migration checklist  {% id="migration-checklist" %}

{% callout type="note" %}
  Automate this migration with a coding agent. If you use a coding agent that supports skills (like Antigravity), install the [gemini-api-dev skill](/docs/coding-agents#gemini-api-dev) and run:

  ```none
  /gemini-api-dev migrate my app to Gemini 4 Carbon
  ```

{% /callout %}

### Migrate from Gemini 4 Argon  {% id="migrate-from-gemini-4-argon" %}

If you already run `gemini-4-argon`, upgrading to `gemini-4-carbon` requires no request schema changes:

* **Update the model ID:** Change your model string from `gemini-4-argon` to `gemini-4-carbon`.
* **Account for longer thinking:** Carbon spends more thinking tokens per turn than Argon on complex tasks. Keep `thinking_level` at `medium` (default) unless a workload needs `high`, and make sure your `max_output_tokens` and HTTP timeouts allow for longer reasoning passes.
* **Use Neon or Hydrogen where speed matters:** Use [`gemini-4-neon`](/docs/whats-new-gemini-4-neon?generate-content=true) for complex software engineering, knowledge work, and science workflows with faster end-to-end task completion, or [`gemini-4-hydrogen`](/docs/whats-new-gemini-4-hydrogen?generate-content=true) for everyday coding and interactive loops.

### Migrate from Gemini 3 and earlier  {% id="migrate-to-gemini-4-carbon" %}

* **Update the model ID:** Change your model string to `gemini-4-carbon`.
* **Set `max_output_tokens` explicitly:** The default is 64K for streaming and SDK calls, and 32K for non-streaming REST calls.
* **Raise caps lower than 32K:** Raise any cap lower than 32K to at least 32,768. Use `thinking_level` to reduce token spend.
* **Plan for long decode:** For tasks above the per-request cap, use the latest SDK or add a `continuation_token` loop.
* **Replace `thinking_budget` with `thinking_level`:** `thinking_budget` still works and maps to the nearest `thinking_level`, but it returns a warning. Test your workload at `low`, `medium`, and `high`.
* **Move off explicit context caching:** Explicit caching (`cachedContents` / `caches.create`) is not supported on Gemini 4 Carbon and returns an error. Remove calls that create or pass `cached_content` in `GenerateContentConfig`. [Implicit caching](/docs/caching?generate-content=true) is enabled by default for prompts of at least 4,096 tokens and discounts cached input tokens by 95% on cache hits.
* **Remove deprecated parameters:** Remove `temperature`, `top_p`, `top_k`, and `candidate_count` from requests. If provided, sampling parameters are ignored.
* **Increase client timeouts:** Set HTTP client timeouts to at least 20 minutes per call.
* **Preserve thought signatures:** Pass the full conversation history, including [thought signatures](/docs/thinking?generate-content=true#signatures), in multi-turn and function-calling requests.
* **Review your cost estimates:** Every token the model processes is billed, including internal tool system instructions and function declarations when using grounding (see [Pricing](/docs/whats-new-gemini-4-carbon?generate-content=true#pricing)).

## Pricing  {% id="pricing" %}

{% callout type="note" %}
  Gemini 4 Carbon is not available on the Free tier. Every token the model processes is counted and billed, including thinking tokens and internal tool system instructions and function declarations when using grounding.

{% /callout %}

{% tabs %}
  {% tab title="Standard" %}
  {% table %}
  * Feature
  * Free Tier
  * Paid Tier, per 1M tokens in USD

  ---

  * Input price
  * Not available
  * $4.00

  ---

  * Output price (including thinking tokens)
  * Not available
  * $20.00

  ---

  * Context caching price
  * Not available
  * $0.20   
  Implicit caching only (explicit caching is not supported).

  ---

  * Grounding with Google Search{% sup %}*{% /sup %}
  * Not available
  * 5,000 free search requests per month (shared across all Gemini 3 and newer models),
  then $14 per 1,000 requests (subject to a [daily cap](/docs/pricing#pricing-for-tools) of 1,500 requests per day).

  ---

  * Grounding with Google Maps
  * Not available
  * 5,000 requests per month (free, shared across all Gemini 3 and newer models), then $14 / 1,000
  search queries.

  ---

  * Used to improve our products
  * Not available
  * [No](/docs/terms)
  {% /table %}

  {% sup %}*{% /sup %} A customer-submitted request to Gemini may result in one or
    more queries to Google Search. You will be charged for each individual search
    query performed.
    

  {% /tab %}

  {% tab title="Batch" %}
  {% table %}
  * Feature
  * Free Tier
  * Paid Tier, per 1M tokens in USD

  ---

  * Input price
  * Not available
  * $2.00

  ---

  * Output price (including thinking tokens)
  * Not available
  * $10.00

  ---

  * Context caching price
  * Not available
  * $0.10   
  Implicit caching only (explicit caching is not supported).

  ---

  * Used to improve our products
  * Not available
  * [No](/docs/terms)
  {% /table %}

  {% /tab %}

  {% tab title="Flex" %}
  {% table %}
  * Feature
  * Free Tier
  * Paid Tier, per 1M tokens in USD

  ---

  * Input price
  * Not available
  * $2.00

  ---

  * Output price (including thinking tokens)
  * Not available
  * $10.00

  ---

  * Context caching price
  * Not available
  * $0.10   
  Implicit caching only (explicit caching is not supported).

  ---

  * Used to improve our products
  * Not available
  * [No](/docs/terms)
  {% /table %}

  {% /tab %}

  {% tab title="Priority" %}
  {% table %}
  * Feature
  * Free Tier
  * Paid Tier, per 1M tokens in USD

  ---

  * Input price
  * Not available
  * $7.20

  ---

  * Output price (including thinking tokens)
  * Not available
  * $36.00

  ---

  * Context caching price
  * Not available
  * $0.36   
  Implicit caching only (explicit caching is not supported).

  ---

  * Grounding with Google Search{% sup %}*{% /sup %}
  * Not available
  * 5,000 free search requests per month (shared across all Gemini 3 and newer models),
  then $14 per 1,000 requests (subject to a [daily cap](/docs/pricing#pricing-for-tools) of 1,500 requests per day).

  ---

  * Grounding with Google Maps
  * Not available
  * 5,000 requests per month (free, shared across all Gemini 3 and newer models), then $14 / 1,000
  search queries.

  ---

  * Used to improve our products
  * Not available
  * [No](/docs/terms)
  {% /table %}

  {% sup %}*{% /sup %} A customer-submitted request to Gemini may result in one or
    more queries to Google Search. You will be charged for each individual search
    query performed.
    

  {% /tab %}

{% /tabs %}

## Other models  {% id="other-models" %}

* [Choosing a model](/docs/choosing-a-model)
* [Latest Gemini models](/docs/latest-model?generate-content=true)
* [Gemini 4 Neon](/docs/whats-new-gemini-4-neon?generate-content=true)
* [Gemini 4 Hydrogen](/docs/whats-new-gemini-4-hydrogen?generate-content=true)
* [Gemini 4 Argon](/docs/whats-new-gemini-4-argon?generate-content=true)
* [Gemini 3.8 Flash](/docs/whats-new-gemini-3.8?generate-content=true)
* [Gemini 3.6 Flash and 3.5 Flash-Lite](/docs/whats-new-gemini-3.6?generate-content=true)
* [See all models](/docs/models)

## What's next  {% id="whats-next" %}

* Read the [Gemini 4 Carbon developer guide](https://aistudio.google.com/learn/gemini-4-carbon-developer-guide) for prompting and multi-agent patterns.
* Read the [long decode developer guide](/docs/long-decode?generate-content=true) for full streaming, reconnection, and token-counting patterns.
* Learn how thinking levels and thought summaries work in the [thinking guide](/docs/thinking?generate-content=true).
* Process Word, PowerPoint, and Excel files in the [document understanding guide](/docs/document-processing?generate-content=true#office-documents).
* Test Gemini 4 Carbon in [Google AI Studio](https://aistudio.google.com/prompts/new_chat?model=gemini-4-carbon).

