Use Claude Code with Fabric AI Gateway
You can send Claude Code traffic through Fabric AI Gateway by pointing Claude Code at a gateway route and passing a gateway key as a custom header. The gateway then applies your plugins to Claude Code requests, and you can review them in the console. This topic shows you how to start Claude Code through the gateway and confirm that requests arrive.
Prerequisites
Before you begin, make sure you have the following:
- Claude Code installed on your computer.
- A route that uses the Anthropic Messages API, such as
anthropic-route, with these three endpoints exposed:messages,count_tokens, andmodels. Claude Code needs only these endpoints. For the steps, see Connect an LLM provider. - A gateway key for the route. For the steps, see Create a gateway key. For how callers send it, see Authenticate and send a request.
Configure Claude Code to use the gateway
Claude Code reads its settings from a settings.json file, which is the recommended way to point it at the gateway. To configure Claude Code, do the following:
-
Open your Claude Code user settings file,
~/.claude/settings.json. To limit the change to one project, use.claude/settings.jsonin that project instead. -
Add an
envblock with the gateway base URL and the gateway key header: -
Replace
BASE_URLwith the route’s base URL andGATEWAY_KEYwith your gateway key. To get the base URL, select LLMs > Routes, find the route, and then select Copy LLM base URL. -
Restart Claude Code.
The settings do the following:
ANTHROPIC_BASE_URLsends requests to the gateway route instead of the Anthropic API. Use the base URL only, not the individual endpoint paths.ANTHROPIC_CUSTOM_HEADERSadds the gateway key to each request. Usefg-api-keyas the header name. Every route accepts it, unless its Key Auth instance is an older one that sets aheaderslist. In that case, send the key in one of the listed headers, and ask your admin which. For more information, see Authenticate requests with Key Auth.
Treat the gateway key as a secret. Don’t commit a settings file that contains it. For a project-level file, use .claude/settings.local.json, which Claude Code doesn’t share through version control.
To try the gateway for one session without editing a file, set the same two variables in your shell before you run claude.
How Claude Code authenticates to Anthropic
The gateway supplies the Anthropic credential. It adds the API key saved on the connection when it forwards requests to Anthropic, so you only need to send the gateway key to Fabric.
Confirm that requests pass through the gateway
To confirm that Claude Code uses the gateway, do the following:
- In Claude Code, send a message, for example
Hello, is this working?. - In the Fabric console, select Traces. To see traces from every namespace, select Admin, and then select Traces.
- Find the requests from your user on the route.
Open a trace to see the request body, which includes the system prompt and the tool definitions that Claude Code sends with each request. If you attached a routing plugin to the route, the trace also shows the extra calls that the plugin makes.
Next steps
- Add a rate limit to the route. For the steps, see Control traffic with plugins.
- Add fallback routing, so Claude Code keeps working when a provider returns errors. For the steps, see Fail over across providers with the LLM Router.
- Review token usage and estimated cost by model on the LLM tab of Review analytics.

