Connect Claude Code and Codex
Route Claude Code and Codex model calls through the gateway, where your model access rules decide each one.
If you don't see this feature in your console, ask your SecureAuth contact to
enable the llm_gateway feature flag for your organization.
When you finish this page, Claude Code or Codex sends its model calls through the gateway, where your model access rules decide each one and Agent Trail records it.
Get an agent token
The AI gateway authenticates an agent by its agent token, not by a provider API key. Create a custom agent with the API key credential type, and copy the key it shows. The key is shown once, so store it before you close the dialog.
Point the agent at the gateway
Set the agent's base URL to the gateway, and use the agent token as its API key.
- Claude Code – set
ANTHROPIC_BASE_URLtohttps://<your-gateway-url>/gateway/llm/anthropicandANTHROPIC_API_KEYto the agent token. - Codex – set the base URL to
https://<your-gateway-url>/gateway/llm/openai/v1and the API key to the agent token.
Until a model access rule allows a model, the gateway denies every call to it. The gateway refuses a provider API key, with an error that says to use the agent token instead.
Keep a Claude or ChatGPT sign-in
With a sign-in connection, the agent keeps its own claude.ai or ChatGPT sign-in and sends the agent token in the X-SecureAuth-Token header.
Unset ANTHROPIC_API_KEY or OPENAI_API_KEY, because the gateway doesn't pass provider API keys through.
- Claude Code – set
ANTHROPIC_CUSTOM_HEADERS="X-SecureAuth-Token: <token>". - Codex – send the header through its
env_http_headerssetting.
Next steps
Your agent's model calls now go through the gateway, and each one appears in Agent Trail as a Model Call. Decide which models it can call in Model access rules.