Fluxio
← Voltar ao blog

Point Claude Code at a Relay with Environment Variables

Agentes de programação, ao vivoEN

§1 Route Claude Code Through a Relay

Pointing Claude Code at an API relay starts with two settings: the server it should contact and the credential it should send. Environment variables let you change those settings without modifying your project or embedding secrets in source files.

Fluxio is a streaming-first, pay-per-token AI API relay that works with Claude Code and other developer tools. It fits this workflow when you want centralized API access and token-by-token responses. Before configuring anything, confirm that your account supports the Claude Code authentication method and models you plan to use.

§2 Step 1: Prepare Your Terminal and API Key

Install Claude Code using its official installation instructions, then open a terminal where the claude command is available. Obtain your relay API key and keep it out of repositories, screenshots, shared terminal recordings, and support tickets.

The commands below use Bash or Zsh on macOS or Linux. They apply to the current shell and programs launched from it. An already-running Claude Code session will not automatically inherit newly exported variables.

Start by checking whether an old configuration exists. Avoid printing credential values; inspect only the endpoint:

$ printenv ANTHROPIC_BASE_URL

If you already use another provider, note its configuration before replacing it. Also check shell startup files and Claude Code settings for conflicting authentication or endpoint values.

§3 Step 2: Set the Relay Base URL

$ Claude Code uses ANTHROPIC_BASE_URL to select a custom API server. For Fluxio, configure the root API address:
$ export ANTHROPIC_BASE_URL="https://api.fluxioapi.com"

Do not automatically append /v1 because an OpenAI SDK example does. OpenAI-style clients use that suffix with Fluxio, but Claude Code follows the Anthropic-compatible request format. Use the relay’s Claude Code instructions if they specify a different base path.

A shared hostname does not make API formats interchangeable. The relay must support the Anthropic-compatible routes, authentication, and streaming behavior that Claude Code expects.

§4 Step 3: Supply Authentication Safely

For a relay that accepts bearer-token authentication, Claude Code supports ANTHROPIC_AUTH_TOKEN. In Bash, read the key without displaying it or putting the literal secret in shell history:

$ read -s -p "Relay API key: " ANTHROPIC_AUTH_TOKEN; printf '\n'; export ANTHROPIC_AUTH_TOKEN

In Zsh, use its corresponding hidden-input syntax:

$ read -s "ANTHROPIC_AUTH_TOKEN?Relay API key: "; printf '\n'; export ANTHROPIC_AUTH_TOKEN

For this bearer-token setup, remove a competing API-key variable from the current shell:

$ unset ANTHROPIC_API_KEY

If the relay instead instructs you to use ANTHROPIC_API_KEY, follow that method rather than setting both credentials. Authentication requirements are provider-specific; a successful request from an OpenAI SDK does not prove the Claude Code setup is correct.

§5 Step 4: Launch and Verify Claude Code

From the same terminal, enter your project directory and launch the tool:

$ claude

Use /status to inspect the available session and configuration information. Then send a small request, such as asking Claude Code to explain the current directory without changing files. Confirm that the request completes and, where available, appears in your relay usage dashboard.

If you need a specific model, use the exact model identifier published by the relay. A display name such as Claude Haiku 4.5 is not necessarily the API identifier. Avoid guessing model slugs or assuming every listed model supports Claude Code’s tool workflow.

§6 Step 5: Troubleshoot and Keep Configuration Scoped

  • – Unauthorized: Check the key, account balance, authentication method, and conflicting credentials.
  • – Not found: Check the base URL and whether the relay supports Anthropic-compatible routes.
  • – Model unavailable: Verify the exact identifier and account access.
  • – Streaming stalls: Check proxies, VPNs, and network timeouts that may interrupt long-lived responses.

Keep credentials session-scoped unless you have a deliberate persistence strategy. To reset this configuration, run unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN, then restart Claude Code. Remember that relayed requests pass through another service, so review its data-handling terms before sending private code.

Sign up for Fluxio to try the workflow.

Criar uma conta Fluxio →

Mais da corrente