Claude Code logo
Coding agents

Use TokenRex with Claude Code

Configure Claude Code with a Claude-compatible Messages gateway and a private API key.

Setup checked against the linked documentation. Screenshots are reference examples from the tool's publisher, not proof of a TokenRex connection. Live execution inside this third-party app has not been tested; verify a short request before running larger tasks.

Before you start

  • Node.js and Claude Code
  • A TokenRex API key
  • A Claude model ID from the Models page

Setup methods

01

Terminal environment

  1. 1

    Install Claude Code using Anthropic's current installation instructions. Create a TokenRex key and choose an enabled Claude model ID from Models & Pricing.

  2. 2

    Set the private environment variables below in the terminal or secret manager used to launch Claude Code. The base URL does not include /v1.

  3. 3

    Launch claude in your project and run /status to check the provider and selected model.

  4. 4

    Send a short question, then check TokenRex usage. Confirm tool-use behavior separately before allowing edits or terminal commands.

Terminal commands
export ANTHROPIC_BASE_URL="https://tokenrex.ai/api/public"
export ANTHROPIC_AUTH_TOKEN="<your TokenRex API key>"
export ANTHROPIC_MODEL="<exact enabled Claude model ID>"
claude

Setup reference
02

User settings file

  1. 1

    Merge an env block into ~/.claude/settings.json rather than replacing existing permissions or settings.

  2. 2

    Use ANTHROPIC_AUTH_TOKEN for Bearer authentication, or ANTHROPIC_API_KEY for x-api-key authentication when your gateway supports that scheme. Do not set conflicting credentials.

  3. 3

    Keep any file containing your key private. Restart Claude Code and verify with /status and a short request.

Configuration
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://tokenrex.ai/api/public",
    "ANTHROPIC_AUTH_TOKEN": "<your TokenRex API key>",
    "ANTHROPIC_MODEL": "<exact enabled Claude model ID>"
  }
}

Setup reference

Troubleshooting

A non-Claude model fails
Anthropic does not support routing Claude Code to non-Claude models through a gateway. Select a Claude model and verify the Messages protocol, not just the base URL.
Authentication fails
Check that the saved TokenRex key is active and belongs in the tool's API-key field, not its subscription sign-in. Remove accidental spaces, check your wallet balance, and never share the key in screenshots or exported settings.
The model is missing or the request URL returns 404
Copy an exact enabled model ID from Models & Pricing. Follow this method's URL field: some tools expect the versioned base, others the root or full completion address. Check the documented API protocol before changing the path.
Chat works but streaming or tools fail
Test a short plain-text conversation first. Confirm the selected model and installed tool version support the required protocol and capabilities. Enable agent actions only after separately checking streaming and tool calls.

Verify the connection

Send a short message with the selected model, read its response, then confirm the exact model appears in your TokenRex usage. Test streaming and tool use separately before larger agent tasks.