By pointing Claude Desktop ↗︎ at AI Gateway instead of Anthropic directly, you get observability, caching, and centralized credentials for your Anthropic requests, without changing how you use Claude Desktop. Claude Desktop can send third-party inference requests to a custom gateway; this configuration sends those requests to AI Gateway's Anthropic endpoint, authenticated with your Cloudflare gateway token or Cloudflare Access. AI Gateway can supply the Anthropic credentials for you through Unified Billing or a stored provider key (BYOK).
If your gateway is protected by Cloudflare Access, refer to Use with Cloudflare Access.
Before you start, you need:
- For gateway-token authentication, an authenticated gateway and its gateway token. The gateway token must have
Runpermissions. - For gateway-token authentication, your Cloudflare account ID. To find it, refer to Find your account and zone IDs.
- Credentials for Anthropic requests. Use either Unified Billing credits or an Anthropic API key stored in AI Gateway as a provider key (BYOK).
- Claude Desktop installed and updated to the latest version.
-
In Claude Desktop, select Help > Troubleshooting > Enable Developer Mode.
-
Select Developer > Configure Third-Party Inference.
-
In Connection, set the connection type to Gateway.
-
In Gateway credentials, set Credential kind to Static API key.
-
Set Gateway API key to your Cloudflare gateway token.
Replace
<CF_AIG_TOKEN>with your gateway token.<CF_AIG_TOKEN> -
Set Gateway auth scheme to Bearer.
-
Set the gateway base URL to your gateway's Anthropic endpoint.
Replace
<ACCOUNT_ID>and<GATEWAY_ID>with your values.https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/anthropic -
In Models, add the Claude model you want to use.
Field Value Model ID claude-sonnet-4-5Display name Claude Sonnet 4.5Tier alias sonnet -
In Gateway credentials, select Test connection.
-
Start a Claude Desktop conversation. Requests now route through AI Gateway.
If your gateway is protected by Cloudflare Access, Claude Desktop can authenticate with a short-lived Access token instead of a gateway token. Use a local helper script to fetch the token with cloudflared.
Before you start, set up a custom domain protected by Access with a policy that allows your identity. Install cloudflared on the machine running Claude Desktop.
-
Create a local helper script, replacing
ai-gateway.example.comwith your gateway's custom domain:aig-access.shsh #!/bin/sh exec cloudflared access login --no-verbose --app https://ai-gateway.example.comThe
--no-verboseflag prints only the JSON Web Token (JWT) to standard output, as the helper requires. If Claude Desktop cannot findcloudflared, replace it in the script with the full path returned bycommand -v cloudflared. -
Make the script executable:
chmod +x aig-access.sh -
In Claude Desktop, select Help > Troubleshooting > Enable Developer Mode.
-
Select Developer > Configure Third-Party Inference.
-
In Connection, set the connection type to Gateway.
-
In Gateway credentials, set Credential kind to Helper script and Gateway auth scheme to Bearer.
-
Set the gateway base URL to
https://ai-gateway.example.com/anthropic, replacingai-gateway.example.comwith your gateway's custom domain. -
In Helper Script, set the path to your local
aig-access.shscript. Use the full path to the file. -
In Models, add the Claude model you want to use.
-
In Gateway credentials, select Test connection. Complete the Access login flow when prompted, then start a Claude Desktop conversation.
To confirm traffic reaches AI Gateway, refer to Verify it works.