Skip to content

feat(gemini): add Gemini 4 Carbon support - #8661

Merged
Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
xy3xy3:feat/gemini-4-carbon-8658
Nov 16, 2026
Merged

Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
xy3xy3:feat/gemini-4-carbon-8658

Conversation

@xy3xy3

@xy3xy3 xy3xy3 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #8658.

  • Add the official gemini-4-carbon model to Gemini native/CLI fallback catalogs, Antigravity defaults, and frontend whitelist/mapping presets. Keep legacy Google One models unchanged; do not invent Carbon preview or tier routing aliases.
  • Honor low/medium/high thinking in direct Gemini compatibility and the Antigravity transformer. Preserve upstream defaults and mapped model selection, convert legacy budgets to levels, and avoid sending Carbon thinkingBudget.
  • Add standard/priority fallback pricing, implicit-cache pricing, resource-name/tier price normalization, and synchronous context/output metadata.
  • Add catalog, thinking, mapped-request, pricing, and frontend regression tests.

Validation

  • Passed full package tests: gemini, geminicli, antigravity, domain.
  • Passed focused handler model-list tests and service Carbon pricing, cache-storage, and thinking tests.
  • Passed 587 frontend critical tests across 30 files, typecheck, full ESLint, and Vite production build.
  • gofmt and git diff --check passed.
  • Full backend unit run was attempted but compiler processes were killed by the container memory limit. Focused service tests passed with GOMAXPROCS=1, GOGC=10, -p=1 and service inlining disabled. Integration tests and golangci-lint were not run; CI still needs to run.

Scope and caveats

  • No live provider-account testing. Antigravity uses the officially published bare identifier; account availability still depends on Ultra/Enterprise entitlement and upstream rollout.
  • Prices follow the repository's current static introductory-price convention: $2 input / $10 output / $0.10 cached input per million tokens through November 30, 2026. Google's December 1 rates double and require a pricing-data/fallback update; this change does not add a scheduled pricing engine.
  • Uses the existing synchronous generateContent path (65,536 max output); does not implement Carbon's separate long-decode/background continuation API.

Official references

@r266-tech

Copy link
Copy Markdown
Contributor

在 macOS arm64 上使用 Go 1.27.3 独立验证了未修改的 PR head d70a23f84b7329ca76dacae590df132993d415fc,补充一组完整本地后端结果:

  • GOTOOLCHAIN=go1.27.3 go test -tags=unit ./... -json:退出 0,26,916 个通过、41 个条件跳过的测试/子测试事件。
  • GOTOOLCHAIN=go1.27.3 go test -tags=integration ./... -json:退出 0,16,180 个通过、16 个条件跳过的测试/子测试事件。
  • CI 固定的 golangci-lint run --timeout=30m ./...(v2.14.0):退出 0,0 issues。

以上 Go 计数包含父测试和子测试事件,不是独立叶子用例数。使用标准命令完成,没有修改 PR 源码。真实 provider 账户、Antigravity 的账户可用性和 long-decode 仍未验收。

AI 披露:这些独立检查由 AI agent 自治执行,未经人工复核。

zacharyyyang added a commit to zacharyyyang/sub2api that referenced this pull request Nov 11, 2026
feat(gemini): 支持 Gemini 4 Carbon(移植上游 Wei-Shaw#8661,含定价/目录/thinking)
doublepi123 added a commit to doublepi123/sub2api that referenced this pull request Nov 12, 2026
Merges d70a23f (single commit on top of 10ba8f9, an ancestor of
fork main) with --no-ff so the PR author's history is preserved.

Conflict: backend/internal/pkg/antigravity/claude_types_test.go
- Fork had already slimmed TestDefaultModels_ContainsCallableEndpointModels
  to the callable set (dropping legacy image aliases). Kept the fork list
  and only added the PR's new "gemini-4-carbon" entry; no legacy aliases
  reintroduced.

Carbon follows the published model ID only (no invented -low/-high
routing aliases in the default mapping); legacy budget_tokens is
converted to thinkingLevel and thinkingBudget is never sent for Carbon.
Gemini 4 Argon three-tier aliases and existing Haiku/Kiro behaviour are
untouched.
doublepi123 added a commit to doublepi123/sub2api that referenced this pull request Nov 12, 2026
Production probe of account 8 (Ultra, paidTier=g1-ultra-lite-tier) shows
Antigravity's fetchAvailableModels registers Carbon only as
gemini-4-carbon-low/-medium/-high, with
defaultAgentModelId=gemini-4-carbon-medium and no bare gemini-4-carbon.
The bare ID belongs to the Gemini API/AI Studio surface, so PR Wei-Shaw#8661's
bare-only Antigravity mapping would forward an ID upstream does not list.

Adaptation on top of Wei-Shaw#8661:
- DefaultAntigravityModelMapping: bare gemini-4-carbon aliases to
  gemini-4-carbon-medium, and the three suffix identities are added.
- antigravityDefaultPassthroughModels: injects the three suffixes for
  accounts with an explicit model_mapping (bare stays unmapped there).
- The dynamic thinking-variant resolver treats a bare -> own-level-suffix
  mapping as a default tier, not a foreign alias, and defaults bare
  Carbon to medium when the client does not pin a level.
- Native Gemini path: legacy thinkingConfig.thinkingBudget is converted to
  thinkingLevel and removed for Carbon; suffix requests just drop the
  budget. The Claude/OpenAI compatibility paths already never emit
  thinkingBudget for Carbon via buildGenerationConfig.
- Static Antigravity catalog and IsGeminiReasoningModel use the three
  suffixes; the Gemini API catalogs (pkg/gemini, pkg/geminicli, frontend
  gemini list) keep the bare ID so surfaces stay separate.
- Frontend Antigravity whitelist/presets use the suffixes; the bare key
  maps to medium as the client alias.

Pricing already normalizes Carbon suffixes to its own card (2/10/0.1 per
MTok, 1.8x priority) before any Argon rule; the new test pins that the
suffixes never fall through to Argon or a free model. Argon's three tiers,
Haiku/Kiro behavior and the auto-disabled newapi channel 14 are untouched.
@universonic

Copy link
Copy Markdown

Please 😭 @Wei-Shaw

@Wei-Shaw
Wei-Shaw merged commit 03c1749 into Wei-Shaw:main Nov 16, 2026
9 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[适配] Gemini 4 Carbon

4 participants