Skip to content

[AI Gateway] Use gateway token for Claude Code; add Bedrock and Vertex docs#31681

Open
adriandlam wants to merge 1 commit into
cloudflare:productionfrom
adriandlam:docs/ai-gateway-claude-code
Open

[AI Gateway] Use gateway token for Claude Code; add Bedrock and Vertex docs#31681
adriandlam wants to merge 1 commit into
cloudflare:productionfrom
adriandlam:docs/ai-gateway-claude-code

Conversation

@adriandlam

Copy link
Copy Markdown
Contributor

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.

File Change
integrations/coding-agents/claude-code.mdx Swap ANTHROPIC_API_KEY for the gateway token; add Bedrock + Vertex sections

What changed

  • Anthropic (updated) — ANTHROPIC_API_KEY now holds the Cloudflare gateway token (<CF_AIG_TOKEN>)
    rather than an Anthropic API key
  • Amazon Bedrock (new) — routes Claude Code through AI Gateway's Bedrock endpoint using
    CLAUDE_CODE_USE_BEDROCK, ANTHROPIC_BEDROCK_BASE_URL, and CLAUDE_CODE_SKIP_BEDROCK_AUTH. The gateway signs requests with the AWS credentials stored via BYOK
  • Google Vertex AI (new) — routes Claude Code through AI Gateway's Vertex endpoint using CLAUDE_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 BYOK

Notes

  • Each new section provides macOS/Linux and Windows (PowerShell) tabs, matching the existing
    Anthropic section.
  • Auth wording for Bedrock/Vertex is backed by the respective provider docs.
  • No files were renamed or moved, so no redirects are required.

Documentation checklist

  • The change adheres to the documentation style guide.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any
    incorrect or out of date information that this PR fixes.

@github-actions github-actions Bot added product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ size/s labels Jun 24, 2026
@superhighfives superhighfives marked this pull request as ready for review June 25, 2026 06:43
Copilot AI review requested due to automatic review settings June 25, 2026 06:43
@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review

⚠️ 2 warnings found in commit cbe6f1b.

Code Review

This code review is in beta and may not always be helpful — use your judgment.

Warnings (2)
File Issue
ai-gateway/integrations/coding-agents/claude-code.mdx line 39 Wrong value for ANTHROPIC_API_KEY — The added step sets ANTHROPIC_API_KEY="<CF_AIG_TOKEN>", but the page prerequisites require an Anthropic API key, the note describes ANTHROPIC_API_KEY as the Anthropic key, and the Anthropic provider docs use apiKey for the Anthropic key and the gateway token only in cf-aig-authorization. Fix: Use the user's Anthropic API key for ANTHROPIC_API_KEY and keep the gateway token only in ANTHROPIC_CUSTOM_HEADERS. If the intent is to use Unified Billing without a provider key, remove the Anthropic API key prerequisite and update the note.
ai-gateway/integrations/coding-agents/claude-code.mdx line 76 Bedrock base URL missing trailing slashANTHROPIC_BEDROCK_BASE_URL ends with .../aws-bedrock/bedrock-runtime/<AWS_REGION> without a trailing slash, while the AI Gateway Bedrock docs use .../bedrock-runtime/us-east-1/ and append the model path after the region. SDK URL joining can drop the region if the slash is omitted. Fix: Add a trailing slash after <AWS_REGION> in both the macOS/Linux and Windows Bedrock examples.

Style Guide Review

✅ No style-guide issues found.

Commands

Only codeowners can run commands. Post a comment with the command to trigger it.

Command Description
/review Runs a review now. Incremental if a prior review exists, full if not.
/full-review Re-reviews the entire PR diff from scratch, ignoring incremental history. Useful after a rebase, when you want a fresh review, or if the bot gets out of sync and reports issues that no longer exist.
/ignore-review-limit Permanently lifts the 2-review automatic limit for this PR. Future pushes will trigger reviews as normal.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_KEY and the cf-aig-authorization header.
  • 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.
Comment on lines +75 to +77
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"
Comment on lines +85 to +87
$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"
@superhighfives

Copy link
Copy Markdown
Contributor

/bonk review this

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_KEY to the user's Anthropic API key and keep the gateway token only in ANTHROPIC_CUSTOM_HEADERS if 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same trailing-slash issue as the macOS/Linux snippet above.

Suggested change
$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>/"

@ask-bonk

ask-bonk Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Done! I submitted a review on PR #31681.

Key findings:

  1. Internal inconsistency in Anthropic section — The code now sets ANTHROPIC_API_KEY to the AI Gateway token, but the description, introduction, prerequisites, and note still describe the old flow (user provides their own Anthropic API key, Anthropic bills directly, no BYOK). This is confusing for readers and needs to be resolved by either updating all the surrounding text or reverting the ANTHROPIC_API_KEY change.

  2. Bedrock URL missing trailing slash — Both macOS/Linux and Windows examples for the Bedrock base URL omit the trailing / after <AWS_REGION>. The AI Gateway Bedrock docs include it, and skipping it can cause path-joining issues when the client appends the model path.

  3. New Bedrock and Vertex sections — These additions are well-structured and match the existing format. No issues there beyond the Bedrock slash.

github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.