Claude Code. Powered by the Gemini CLI session you already have.
Route Claude Code requests through Gemini CLI authentication using a lightweight local compatibility proxy. No separate Gemini API key required.
Sends Anthropic-formatted /v1/messages requests with nested role blocks and tool schemas.
- Target: localhost:8080
- Schema: Anthropic Messages v1
- Protocol: HTTP/1.1 SSE
Pure Node.js stdlib proxy translating multi-turn structures, uppercasing schemas, and wrapping responses into SSE streams.
- Auth Check: ~/.pi/agent/auth.json
- Schema: OpenAPI Type Normalizer
- Resilience: Auto 429 → Flash Failover
Google Cloud Code Assist API executing reasoning models via the user's active Google OAuth session.
- Primary: gemini-2.5-pro
- Fallback: gemini-2.5-flash
- Auth: Google PKCE Bearer
Why CodeWeaver exists
Claude Code provides one of the most effective developer agent experiences, but standard usage requires separate Anthropic platform billing. CodeWeaver bridges developer workflows without compromising agent autonomy.
Separate API Billing
Developers frequently already have access to Google Workspace or Gemini CLI subscriptions, yet running Claude Code traditionally demands a separate paid Anthropic API account.
Heavyweight Dependencies
Standard multi-provider proxies require Python runtimes, 40+ npm dependencies, Docker daemon containers, or separate hosted relay infrastructure that complicates local setups.
CodeWeaver Local Architecture
A single standalone script built strictly on Node.js core libraries (http, crypto, fs). Authenticate once with Google, set one environment variable, and start coding.
OAuth session handoff & SSE request translation
CodeWeaver operates entirely on local loopback without third-party servers. Here is how Google OAuth token handoff and runtime translation function under the hood.
01. Google OAuth Session Handoff
CodeWeaver avoids static API keys by integrating with the same OAuth PKCE credentials used by Google's Gemini CLI tools.
-
Local PKCE Receiver: Running
node proxy.js --logincreates an ephemeral HTTP callback listener onlocalhost:8085and generates a cryptographic SHA-256 code challenge. -
Credential Storage: Successfully negotiated OAuth tokens are cached locally in
~/.pi/agent/auth.jsonorconfig.jsonwith user-level read/write permissions. -
Automatic Refresh: When an access token nears expiry (within 120 seconds of
expires), CodeWeaver transparently contactsoauth2.googleapis.com/tokenwith the refresh token and rewrites the cache file in background. -
Project Provisioning: Queries Google's Cloud Code Assist endpoint (
loadCodeAssist) to discover the target companion project ID automatically.
02. Protocol & Schema Translation
Claude Code and Gemini Cloud Code speak fundamentally different wire protocols. CodeWeaver transforms requests and streams without buffering latency.
-
Role Normalization: Maps Anthropic multi-turn messages (
user,assistant) to Gemini'suserandmodelstructure, folding sequential turns cleanly. -
Strict OpenAPI Sanitization: Google's endpoint rejects JSON schema specifications containing
$schema,exclusiveMinimum, or lowercase type primitives. CodeWeaver uppercases all parameter types toOBJECT,STRING,INTEGER, etc. -
SSE Stream Framing: Ingests raw Gemini chunked JSON from
streamGenerateContentand formats Anthropic Server-Sent Events (message_start,content_block_delta,message_stop) in real time. -
Self-Healing 429 Failover: If Gemini Pro returns a
429 RESOURCE_EXHAUSTEDquota limit, CodeWeaver instantly re-routes the chunk togemini-2.5-flashso the agent never aborts mid-task.
{
"model": "claude-3-5-sonnet",
"messages": [
{
"role": "user",
"content": "List files in directory"
}
],
"tools": [{ "name": "ls", "input_schema": { "type": "object" } }],
"stream": true
}
{
"project": "cloudaicompanion-prod-...",
"model": "gemini-2.5-pro",
"request": {
"contents": [
{
"role": "user",
"parts": [{ "text": "List files in directory" }]
}
],
"tools": [{ "functionDeclarations": [...] }]
}
}
Claude Code to Gemini Model Routing
Claude Code enforces a client-side whitelist in its interactive model selector. CodeWeaver resolves these requests to the appropriate Gemini enterprise engine with automatic quota failover.
| Claude Code Model Flag | Target Gemini Engine | Automatic 429 Fallback | Recommended Use Case |
|---|---|---|---|
| claude-3-7-sonnet / claude-3-5-sonnet | gemini-2.5-pro | gemini-2.5-flash | Deep multi-file reasoning, refactors, and architectural plans |
| claude-3-5-haiku | gemini-2.5-flash | Primary Tier | High-throughput tasks, fast completions, unit test runs |
| claude-3-opus | gemini-3.1-pro-preview | gemini-2.5-flash | High-depth algorithmic synthesis and extended context evaluation |
| claude-fable | gemini-3.1-flash-lite | gemini-2.5-flash | Atomic linting checks and sub-second terminal feedback |
Quickstart Configuration
Set up CodeWeaver in less than 2 minutes. Requires Node.js 18 or higher. No npm install required.
Clone Repository
Clone the repository. Zero external npm dependencies are required.
Authenticate Google Session
Starts local OAuth receiver on port 8085 to save credentials to local config.
Start Proxy Gateway
Starts the reverse proxy listening on port 8080 (or port 8099 by default).
Launch Claude Code
Point Claude Code's base URL environment variable to your local proxy.
Avoid exporting environment variables each session by setting CodeWeaver in your Claude Code settings file:
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:8080",
"ANTHROPIC_AUTH_TOKEN": "sk-local-proxy"
}
}
Architectural Comparison
How CodeWeaver compares to standard multi-provider proxy solutions.
| Architecture Property | CodeWeaver | Official Anthropic | LiteLLM / Multi-Proxies |
|---|---|---|---|
| Runtime Dependencies | ✓ 0 npm packages (Node stdlib only) | × Proprietary client | × 40+ Python / Node packages |
| Authentication Model | ✓ Google OAuth (Gemini CLI session) | Anthropic API Key ($$$) | Per-provider API Keys |
| Vertex Schema Translation | ✓ Automated uppercase sanitization | N/A | Manual mapping |
| Quota Failover | ✓ Pro → Flash auto fallback on 429 | × Process fails | Custom retry policy needed |
| Host Footprint | ✓ Lightweight script (~28 KB) | CLI installation | Docker / Virtualenv required |
Google restricted certain Cloud Code Assist Gemini CLI OAuth endpoints to enterprise/workspace subscriptions. CodeWeaver remains a completely open-source educational reference for high-performance Node.js proxy architectures, showing how to achieve SSE streaming translation and OpenAPI schema sanitization with zero runtime npm dependencies.