Google 11 月 10 日开放 Gemini 4 Carbon 之后,Interactions API 的 JSON 该如何设置 thinking_level、background 长输出和 usage,赶在 12 月 1 日涨价之前?

仅付费档。11 月 30 日前 $2/$10,其后 $4/$20。thinking_level 为 low、medium 或 high;长输出需要 background 和更高的 max_output_tokens。

把 model 改成 gemini-4-carbon 并不等于请求写完了。 2026 年 11 月 10 日,Google 在付费 Gemini API、Google AI Studio,以及 AI Ultra 订阅的 Antigravity 中开放 Gemini 4 Carbon。促销价到 11 月 30 日为止:输入每百万 token $2,输出每百万 $10,输出含 thinking token。12 月 1 日起改为 $4 和 $20。隐式缓存命中打 95 折($0.10,之后 $0.20)。Carbon 不在免费档。

本文写于 2026 年 11 月 13 日,依据 11 月 10 日的开发者指南和 What's new。三天前我们写过 Fable 5.2 的 effort 与 usage。Carbon 的开关在 Interactions API:generation_config.thinking_level、background 和 usage。

11 月 10 日开放了什么

Google 把 Carbon 放在长程工程、密集多模态文件和科学工作上,称为最强推理模型。模型 ID 是 gemini-4-carbon。默认思考档位是 medium。输入、thinking 和输出共用 1,048,576 token 窗口。同步响应仍在 65,536 token 停下,除非你打开长输出。

gemini-4-argon 共用这扇窗口、同一组 thinking_level、内置工具,以及同一档促销单价。Carbon 每一轮会花更多 thinking token。交互式编码留在 Argon。根因、架构和验证循环再交给 Carbon。

时段输入 / 百万输出(含 thinking)/ 百万缓存输入 / 百万
截至 2026 年 11 月 30 日$2$10$0.10
2026 年 12 月 1 日起$4$20$0.20

请求 JSON 与 thinking_level

POST https://generativelanguage.googleapis.com/v1beta/interactions,带头 x-goog-api-key 和 Content-Type: application/json。深度写在 generation_config.thinking_level,不是数字预算。

{
  "model": "gemini-4-carbon",
  "input": "Analyze this payment pipeline for race conditions during retries and rewrite the locks.",
  "generation_config": {
    "thinking_level": "medium"
  }
}
thinking_levelCarbon 指南建议的用途
low路由、分类、定点抽取
medium默认。多数编码和 agent 回合
high根因调试、形式化数学、架构

不写 thinking_level 时服务端用 medium。Carbon 指南写明的值是 low、medium、high。Interactions 的公共枚举里还有 minimal 和 xhigh,那是给其他模型的;Carbon 页面没列出之前不要发。 thinking_budget 已弃用,会返回警告。max_output_tokens 把 thinking 和可见文本算在一起,上限太低会在推理结束前截断答案。

background 与长输出

要超过 65,536 token,把顶层 background 设为 true,并把 max_output_tokens 设到 65536 以上。上限是 1,048,576 减去输入。background: true 但不写 max_output_tokens,仍然停在 64K。

{
  "model": "gemini-4-carbon",
  "input": "Write a complete proof of the prime number theorem.",
  "background": true,
  "generation_config": {
    "thinking_level": "high",
    "max_output_tokens": 262144
  }
}

Carbon 指南在 status 为 in_progress 或 queued 时轮询。Interaction 资源还有 completed、failed、cancelled、incomplete、requires_action、requires_continuation。incomplete 表示撞上了上限。HTTP 上用 GET /v1beta/interactions/{id} 读取。入门文档里的后台示例在这次 GET 上带了头 Api-Revision: 2026-05-20。

长输出的每一跳都会再追加一个 type: model_output 的 steps[]。把所有 text 拼起来。只读 steps[0] 会丢掉后面的段。previous_interaction_id 只延续历史,不会重放 generation_config、tools 或 system_instruction;下一轮要再写 thinking_level。默认 store 为 true(付费档保留 interaction 55 天)。store: false 不能和 background: true 一起用。

旧 Gemini JSON 里要删的字段

从 Gemini 3 或更早迁过来时,What's new 和开发者指南要求改 JSON,而不只是改模型 ID:

  • temperature、top_p、top_k 会被忽略。开发者指南说它们会返回弃用警告。
  • 删掉显式 cached_content 和 caches.create。隐式缓存从 4,096 token 开始,命中打 95 折。
  • 用 thinking_level 替换 thinking_budget。
  • 若 max_output_tokens 低于 32,768,至少提到 32,768。要省 token 就降低 thinking 档位。
  • 难题可能要好几分钟。用 background,或把 HTTP 客户端超时设到至少 15 分钟。

你自己的 JSON Schema 仍然走响应 schema 字段。见 用 Gemini API 生成结构化 JSON 和 结构化输出是什么。Carbon 不会把判断变成概率;那是另一个端点。

12 月 1 日涨价前怎么记 usage

完成的 interaction 带 usage。公开示例里 7 个输入 + 20 个输出 + 22 个 thought token 等于 total_tokens 49,所以 total_thought_tokens 不在 total_output_tokens 里面。

{
  "id": "v1_example",
  "object": "interaction",
  "model": "gemini-4-carbon",
  "status": "completed",
  "steps": [
    {
      "type": "model_output",
      "content": [{ "type": "text", "text": "..." }]
    }
  ],
  "usage": {
    "total_input_tokens": 7,
    "total_cached_tokens": 0,
    "total_output_tokens": 20,
    "total_thought_tokens": 22,
    "total_tool_use_tokens": 0,
    "total_tokens": 49,
    "input_tokens_by_modality": [{ "modality": "text", "tokens": 7 }]
  }
}

未缓存输入按输入价,total_cached_tokens 按该价格的 5%,total_output_tokens 加 total_thought_tokens 按输出价。不要再加一次 total_tokens。Grounding 的搜索查询另行计费,工具说明也算已处理 token。把整个 usage 对象存下来,12 月 1 日的新价格才能套到已有日志上。

Argon 路由与 agent_config

用配置拆开模型,不要全局只留一个。Argon 走快路径,牌价相同;Carbon 接那些会花 thinking token 的回合。

{
  "routes": [
    { "if": { "task": "interactive_coding" }, "model": "gemini-4-argon", "thinking_level": "medium" },
    { "if": { "task": "root_cause" }, "model": "gemini-4-carbon", "thinking_level": "high", "background": true }
  ]
}

托管 agent 把模型写在 agent_config 里。设了 model 时用 generation_config;agent_config 是另一条路。

{
  "agent": "antigravity-preview-09-2026",
  "environment": "remote",
  "input": "Audit the site for Core Web Vitals and return a scorecard.",
  "agent_config": {
    "type": "antigravity",
    "model": "gemini-4-carbon"
  }
}

上线前要核对的 JSON

  1. 请求体是 gemini-4-carbon,thinking_level 为 low、medium 或 high,且没有 temperature、top_p、top_k、thinking_budget、cached_content。
  2. 必须超过 64K token 的调用同时写了 background: true 和高于 65536 的 max_output_tokens。
  3. 解析器拼上每一个 model_output 的 text,并记下 status。
  4. 账单分开记输入、缓存输入、输出和 thought token,并准备好 12 月 1 日的价格。

在本地用 JSON 校验、JSONPath($.usage.total_thought_tokens)和 JSON 对比 对照上一份请求。数据不会上传。

常见问题

gemini-4-carbon 在免费档吗?

不在。What's new 写明 Carbon 只在付费档。促销价 $2/$10 到 2026 年 11 月 30 日,之后是 $4/$20。

thinking_level 能写 xhigh 吗?

Carbon 指南只写了 low、medium、high。minimal 和 xhigh 出现在给其他模型的 Interactions 枚举里。不要把 Claude 的 effort 值抄进这个字段。

为什么答案停在 64K token?

同步响应停在 65,536。把 background 设为 true,并把 max_output_tokens 设到 65536 以上。只开 background 仍停在 64K。status 为 incomplete 表示撞上了上限。

账单该用 total_tokens 吗?

不要。未缓存输入按输入价,total_cached_tokens 按 5%,total_output_tokens 加 total_thought_tokens 按输出价。再加 total_tokens 会重复计算。

previous_interaction_id 会保留 thinking_level 吗?

不会。下一轮要重发 generation_config、tools 和 system_instruction。这个 id 保留的是历史。

显式上下文缓存还能留吗?

不能。删掉 cached_content。隐式缓存从 4,096 token 开始,命中打 95 折。

小结

2026 年 11 月 10 日开放的 Carbon,改的是模型想多久,以及 11 月 30 日之后你付多少。 用 gemini-4-carbon,thinking_level 取 low、medium 或 high。答案必须超过 64K 时,background: true 要配上高于 65536 的 max_output_tokens。thought token 和可见输出分开记账,采样字段和显式缓存在请求发出前删掉。