feat(infra): Anthropic reverse-proxy relay for Cloud Run#209
Merged
Conversation
…cp-relay) A ~110-line, zero-dep transparent relay: forwards /v1/* (streaming included) to api.anthropic.com from Cloud Run. Lets a client on a network that can't reliably reach Anthropic (flaky local proxy) point ANTHROPIC_BASE_URL at the relay instead — GCP egress to Anthropic is stable. Security: the real Anthropic key lives only in Secret Manager and is injected server-side; clients authenticate with a separate, revocable RELAY_TOKEN sent as x-api-key (key-swap gate). NOT an OpenClaw-style billing proxy — no anthropic-beta:claude-code spoofing, no OAuth reuse; requests bill normally. deploy.sh handles secrets + IAM + Cloud Run deploy and prints the config.env lines. Deployed live to oratis-491316 (us-central1). Note: LISA's loadConfigEnv does NOT override an already-set env var, so a shell/launchd ANTHROPIC_BASE_URL shadows config.env — the Mac's serve-command.txt uses `env -u ANTHROPIC_BASE_URL` so config.env wins. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
Reviewed. Security ✓: no hardcoded secrets in the diff (the |
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.
Transparent Anthropic relay on Cloud Run (
packaging/gcp-relay/) so a China-side client can reach Claude reliably by pointingANTHROPIC_BASE_URLat it instead of a flaky local proxy./v1/*incl. streaming toapi.anthropic.com.RELAY_TOKENasx-api-key.anthropic-beta:claude-codespoof / OAuth reuse; bills normally (researched: those get fingerprinted + blocked by Anthropic).deploy.sh= secrets + IAM + deploy. Live on oratis-491316/us-central1.Gotcha documented:
loadConfigEnvdoesn't override an existing env var, so a launchd/shellANTHROPIC_BASE_URLshadows config.env → serve-command.txt usesenv -u.🤖 Generated with Claude Code