[AI Gateway] Use gateway token for Claude Code; add Bedrock and Vertex docs#31681
[AI Gateway] Use gateway token for Claude Code; add Bedrock and Vertex docs#31681adriandlam wants to merge 1 commit into
Conversation
Review
Code ReviewThis code review is in beta and may not always be helpful — use your judgment. Warnings (2)
Style Guide Review✅ No style-guide issues found. CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
There was a problem hiding this comment.
Pull request overview
Updates the AI Gateway “Claude Code” integration guide to route requests through AI Gateway using gateway authentication, and expands the page with setup instructions for routing Claude Code via Amazon Bedrock and Google Vertex AI provider endpoints.
Changes:
- Updates the Anthropic setup commands to use the AI Gateway token in
ANTHROPIC_API_KEYand thecf-aig-authorizationheader. - Adds a new “Use Amazon Bedrock” section with OS-specific environment variable setup.
- Adds a new “Use Google Vertex AI” section with OS-specific environment variable setup.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <Steps> | ||
|
|
||
| 1. Set the base URL to your gateway's Anthropic endpoint, pass your Anthropic API key, and send your gateway token in the `cf-aig-authorization` header. The following commands set these as shell environment variables for the current session. To persist them, add them to your shell profile (for example, `~/.zshrc` or `~/.bashrc`) or to Claude Code's [`settings.json`](https://docs.anthropic.com/en/docs/claude-code/settings#settings-files) under the `env` key. | ||
| 1. Set the base URL to your gateway's Anthropic endpoint and send your gateway token both in the `ANTHROPIC_API_KEY` and the `cf-aig-authorization` header. The following commands set these as shell environment variables for the current session. To persist them, add them to your shell profile (for example, `~/.zshrc` or `~/.bashrc`) or to Claude Code's [`settings.json`](https://docs.anthropic.com/en/docs/claude-code/settings#settings-files) under the `env` key. |
| export CLAUDE_CODE_USE_BEDROCK="1" | ||
| export ANTHROPIC_BEDROCK_BASE_URL="https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/aws-bedrock/bedrock-runtime/<AWS_REGION>" | ||
| export CLAUDE_CODE_SKIP_BEDROCK_AUTH="1" |
| $env:CLAUDE_CODE_USE_BEDROCK = "1" | ||
| $env:ANTHROPIC_BEDROCK_BASE_URL = "https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/aws-bedrock/bedrock-runtime/<AWS_REGION>" | ||
| $env:CLAUDE_CODE_SKIP_BEDROCK_AUTH = "1" |
|
/bonk review this |
There was a problem hiding this comment.
This is a useful expansion — adding Bedrock and Vertex paths gives readers more flexibility.
However, the Anthropic section now has significant internal inconsistencies. The code sets ANTHROPIC_API_KEY to the gateway token, but the frontmatter description (line 3), introduction (line 13), prerequisites (line 21), and note (lines 24-26) still describe the old flow where the user provides their own Anthropic API key and Anthropic bills them directly. The note even says 'This configuration does not use BYOK' and 'Anthropic bills you for model usage' — neither of which matches the new token-only setup.
Please either:
- Update the surrounding text to match the new code (remove the Anthropic API key prerequisite, rewrite the note to explain how gateway auth works, and update the description/intro), OR
- Revert
ANTHROPIC_API_KEYto the user's Anthropic API key and keep the gateway token only inANTHROPIC_CUSTOM_HEADERSif that was not the intended change.
Also, the Bedrock base URL examples are missing the trailing slash after <AWS_REGION>. The AI Gateway Bedrock docs show the URL ending with .../bedrock-runtime/<AWS_REGION>/, and omitting the slash can cause path-joining issues.
| <Steps> | ||
|
|
||
| 1. Set the base URL to your gateway's Anthropic endpoint, pass your Anthropic API key, and send your gateway token in the `cf-aig-authorization` header. The following commands set these as shell environment variables for the current session. To persist them, add them to your shell profile (for example, `~/.zshrc` or `~/.bashrc`) or to Claude Code's [`settings.json`](https://docs.anthropic.com/en/docs/claude-code/settings#settings-files) under the `env` key. | ||
| 1. Set the base URL to your gateway's Anthropic endpoint and send your gateway token both in the `ANTHROPIC_API_KEY` and the `cf-aig-authorization` header. The following commands set these as shell environment variables for the current session. To persist them, add them to your shell profile (for example, `~/.zshrc` or `~/.bashrc`) or to Claude Code's [`settings.json`](https://docs.anthropic.com/en/docs/claude-code/settings#settings-files) under the `env` key. |
There was a problem hiding this comment.
This step text says to send the gateway token in both ANTHROPIC_API_KEY and cf-aig-authorization, which is the new behavior. However, the prerequisites, note, and intro still describe the old Anthropic-key flow. Make sure the entire section is internally consistent.
| ```bash | ||
| export ANTHROPIC_BASE_URL="https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/anthropic" | ||
| export ANTHROPIC_API_KEY="<ANTHROPIC_API_KEY>" | ||
| export ANTHROPIC_API_KEY="<CF_AIG_TOKEN>" |
There was a problem hiding this comment.
Setting ANTHROPIC_API_KEY to the gateway token is the core change of this PR, but it conflicts with the prerequisite that asks for an Anthropic API key and the note saying Anthropic bills the user. Clarify whether this relies on Unified Billing (no user Anthropic key needed) or some other mechanism.
| ```powershell | ||
| $env:ANTHROPIC_BASE_URL = "https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/anthropic" | ||
| $env:ANTHROPIC_API_KEY = "<ANTHROPIC_API_KEY>" | ||
| $env:ANTHROPIC_API_KEY = "<CF_AIG_TOKEN>" |
There was a problem hiding this comment.
Same as the macOS/Linux snippet above — ANTHROPIC_API_KEY now holds the gateway token, so the surrounding text needs to match.
| ```bash | ||
| export CLAUDE_CODE_USE_BEDROCK="1" | ||
| export ANTHROPIC_BEDROCK_BASE_URL="https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/aws-bedrock/bedrock-runtime/<AWS_REGION>" | ||
| export CLAUDE_CODE_SKIP_BEDROCK_AUTH="1" |
There was a problem hiding this comment.
Missing trailing slash after <AWS_REGION>. The Bedrock provider docs use .../bedrock-runtime/<AWS_REGION>/ — adding the / avoids URL-joining issues if Claude Code appends paths without inserting a separator.
| export CLAUDE_CODE_SKIP_BEDROCK_AUTH="1" | |
| export ANTHROPIC_BEDROCK_BASE_URL="https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/aws-bedrock/bedrock-runtime/<AWS_REGION>/" |
| ```powershell | ||
| $env:CLAUDE_CODE_USE_BEDROCK = "1" | ||
| $env:ANTHROPIC_BEDROCK_BASE_URL = "https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/aws-bedrock/bedrock-runtime/<AWS_REGION>" | ||
| $env:CLAUDE_CODE_SKIP_BEDROCK_AUTH = "1" |
There was a problem hiding this comment.
Same trailing-slash issue as the macOS/Linux snippet above.
| $env:CLAUDE_CODE_SKIP_BEDROCK_AUTH = "1" | |
| $env:ANTHROPIC_BEDROCK_BASE_URL = "https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/aws-bedrock/bedrock-runtime/<AWS_REGION>/" |
|
Done! I submitted a review on PR #31681. Key findings:
|
Summary
Updates the Claude Code setup guide (AI Gateway → Integrations → Coding agents) to authenticate with
the Cloudflare AI Gateway token instead of an Anthropic API key, and adds Amazon Bedrock and Google
Vertex AI setup paths to the same page.
integrations/coding-agents/claude-code.mdxANTHROPIC_API_KEYfor the gateway token; add Bedrock + Vertex sectionsWhat changed
ANTHROPIC_API_KEYnow holds the Cloudflare gateway token (<CF_AIG_TOKEN>)rather than an Anthropic API key
CLAUDE_CODE_USE_BEDROCK,ANTHROPIC_BEDROCK_BASE_URL, andCLAUDE_CODE_SKIP_BEDROCK_AUTH. The gateway signs requests with the AWS credentials stored via BYOKCLAUDE_CODE_USE_VERTEX,ANTHROPIC_VERTEX_BASE_URL,ANTHROPIC_VERTEX_PROJECT_ID,CLOUD_ML_REGION,and
CLAUDE_CODE_SKIP_VERTEX_AUTH. The gateway injects the Google Cloud credentials stored via BYOKNotes
Anthropic section.
Documentation checklist
incorrect or out of date information that this PR fixes.