Skip to content

feat(google): support Cloud Code /v1internal:*generateContent (Antigravity, Gemini CLI) - #265

Open
drakonkat wants to merge 1 commit into
teamchong:mainfrom
drakonkat:feat/cloud-code-v1internal
Open

feat(google): support Cloud Code /v1internal:*generateContent (Antigravity, Gemini CLI)#265
drakonkat wants to merge 1 commit into
teamchong:mainfrom
drakonkat:feat/cloud-code-v1internal

Conversation

@drakonkat

@drakonkat drakonkat commented Sep 2, 2026

Copy link
Copy Markdown

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 normal
generateContent request.

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 / generateContentRequest keys), readGoogleInternalModel. transformGoogleGenerateContent
    recurses into the inner request when it sees the envelope and preserves the outer fields.
  • src/core/proxy.ts: googleUpstream config (default https://cloudcode-pa.googleapis.com),
    /v1internal:*generateContent counted as a Google route, model read from the envelope,
    :countTokens probe skipped and x-api-key stripped on the internal route.
  • src/node.ts / src/worker.ts: GOOGLE_UPSTREAM env (falls back to PXPIPE_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 typecheck
  • pnpm vitest run — 77 files / 1210 tests pass
  • New tests for the envelope and the internal route
  • Live run through Antigravity (needs a Cloud Code OAuth session) — only gemini-3.6-flash / gemini-3.7-flash have measured profiles, other models pass through as unsupported_model

…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.
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.

1 participant