Use Claude Code with Toknix

Step-by-step configuration for Anthropic's official Claude Code terminal agent using Toknix base URL and API keys.

Claude Code is Anthropic's agentic command-line tool. Because Toknix natively supports the Anthropic Messages wire format, you can route Claude Code through Toknix without modifying any source code.

Prerequisites

  1. Node.js 18+ installed on your system.
  2. Claude Code CLI installed globally:
    bash
    npm install -g @anthropic-ai/claude-code
  3. A funded Toknix account with your tk_live_... API key.

Configuration

Point Claude Code to the Toknix gateway by configuring two environment variables in your terminal session or shell profile (~/.zshrc or ~/.bashrc):

bash
export ANTHROPIC_BASE_URL="https://api.toknix.in"
export ANTHROPIC_API_KEY="tk_live_your_actual_key_here"

Shell Persistence

Add these exports to your shell profile file so Claude Code always routes through Toknix automatically on every terminal startup.

Running Claude Code

Launch the agent inside any project repository:

bash
claude

Claude Code will authenticate against Toknix, stream responses with prompt caching, and deduct usage from your prepaid USD balance.

Cost & Efficiency Tips

Claude Code passes extensive repository maps and file histories on every turn. With Toknix automatic prompt caching, repeated turns benefit from up to 90% cost reductions on shared context.