Skip to content

feat(gemini): 支持 Gemini 4 Carbon(移植上游 #8661,含定价/目录/thinking) - #8

Merged
zacharyyyang merged 1 commit into
mainfrom
fork/gemini-4-carbon
Nov 11, 2026
Merged

zacharyyyang merged 1 commit into
mainfrom
fork/gemini-4-carbon

Conversation

@zacharyyyang

Copy link
Copy Markdown
Owner

做了什么

移植上游 PR Wei-Shaw/sub2api#8661(Gemini 4 Carbon 支持,目前上游仍未合并),让 GenUR 的 Antigravity 账号可以调用 gemini-4-carbon 及其 -low/-medium/-high 档位,并按官方价计费。

来源:xy3xy3/sub2api 分支 feat/gemini-4-carbon-8658(commit d70a23f8),以 cherry-pick 方式落到本 fork。

包含内容

  • 模型目录:pkg/antigravity/claude_types.go、pkg/gemini/models.go、pkg/geminicli/models.go 增加 gemini-4-carbon(保留 fork 的 ContextWindow 字段)。
  • 默认映射:domain.DefaultAntigravityModelMapping 增加 gemini-4-carbon。
  • 思考档位:carbonThinkingConfig —— Carbon 只接受 thinking level,不发 thinkingBudget;-low/-medium/-high 档位保持上游目录选择。
  • 定价:billing_service fallback 价 —— 输入 $2/MTok、输出 $10/MTok、缓存读 $0.1/MTok,priority 1.8×(Google 11/30 前 introductory rate);pricing_service 把 -high/-low/-medium/-tiered 归一化到基模型价格牌。
  • 前端:useModelWhitelist 的 Antigravity 预设加入 Carbon。

冲突解决

冲突 处理
antigravity/claude_types.go 的 ClaudeRequest 保留 fork 的 Output *OutputConfig(上游 PR 把它改名为 OutputConfig *ClaudeOutputConfig),删除新类型
carbonThinkingConfig 适配 fork 字段:req.OutputConfig → req.Output
buildGenerationConfig 的 thinking 分支 合成:if !isCarbon && isClaudeThinkingRequested(req, req.Model),既保留 fork 的默认推理模型开启逻辑,又不与 Carbon 档位冲突
模型列表 / 定价别名列表 保留 fork 现有条目(含 ContextWindow、gemini-3.5-flash),追加 Carbon

验证

  • go build ./... 通过;gofmt 干净。
  • Carbon 相关单测:pkg/antigravity、pkg/gemini、service(-run Carbon)全部通过。
  • 已部署到 genur-prod(2026-11-11 12:23,备份 bin/server-linux-arm64.bak-20261111-122300),健康检查 200。
  • 线上冒烟(临时 antigravity 组分 + 临时 Key,验证后已清理):
    • POST /v1/messages {"model":"gemini-4-carbon"} → 200
    • GET /v1/models 已列出 gemini-4-carbon 及 -low/-medium/-high
    • 计费核对(usage_logs id 270940):799 in / 32 out → input_cost=0.010687、output_cost=0.002140、total_cost=0.012827 CNY,符合 $2/$10 per MTok × 6.6825 汇率。

注意

  • composite 分组仍不能直接调 Carbon:这些分组有 model_allowlist + shell 目录,需要另行把 gemini-4-carbon 加进白名单/目录(属业务配置,不在本 PR)。
  • 上游 PR feat(gemini): add Gemini 4 Carbon support Wei-Shaw/sub2api#8661 尚未合并,后续与上游同步时本改动可能被上游版本覆盖,届时以「上游优先 + 保留 fork 字段」再合一次。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T04:26:50.032573Z d52c1ae PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@zacharyyyang
zacharyyyang merged commit 91ea0dd into main Nov 11, 2026
@zacharyyyang
zacharyyyang deleted the fork/gemini-4-carbon branch November 11, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants