feat(google): support Cloud Code /v1internal:*generateContent (Antigravity, Gemini CLI) - #265
Open
drakonkat wants to merge 1 commit into
Open
feat(google): support Cloud Code /v1internal:*generateContent (Antigravity, Gemini CLI)#265drakonkat wants to merge 1 commit into
drakonkat wants to merge 1 commit into
Conversation
…avity, Gemini CLI)
Adds the Cloud Code internal route used by Antigravity and Gemini CLI. The body is a { model, project, request } envelope; the inner generateContent request is transformed and the envelope is preserved. Forwards to cloudcode-pa.googleapis.com by default (GOOGLE_UPSTREAM / googleUpstream override), forwards the client bearer, never injects the Anthropic key, skips the upstream countTokens probe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Antigravity and Gemini CLI talk to Google through the Cloud Code endpoint
https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent(and:generateContent).The body is an envelope
{ model, project, request: { contents, ... } }around a normalgenerateContentrequest.pxpipe only matched
/google-ai-studio/(v1|v1beta)/models/{model}:(stream)generateContent,so the Cloud Code route fell through to the default (Anthropic) upstream and got no compression.
Changes
src/core/google.ts:GOOGLE_INTERNAL_ROUTE/isGoogleInternalPath,unwrapGoogleRequest(
request/generateContentRequestkeys),readGoogleInternalModel.transformGoogleGenerateContentrecurses into the inner request when it sees the envelope and preserves the outer fields.
src/core/proxy.ts:googleUpstreamconfig (defaulthttps://cloudcode-pa.googleapis.com),/v1internal:*generateContentcounted as a Google route, model read from the envelope,:countTokensprobe skipped andx-api-keystripped on the internal route.src/node.ts/src/worker.ts:GOOGLE_UPSTREAMenv (falls back toPXPIPE_UPSTREAM), help text.tests/google.test.ts,tests/gateway.test.ts: envelope unwrap, route detection, upstream selection, header stripping.CHANGELOG.md: Unreleased entry.Test plan
pnpm typecheckpnpm vitest run— 77 files / 1210 tests passgemini-3.6-flash/gemini-3.7-flashhave measured profiles, other models pass through asunsupported_model