Usage with Claude Code

This guide shows how to run Claude Code through ekai-gateway for multi‑provider routing, unified configuration, and detailed usage analytics.

What You Get

  • Single endpoint for Anthropic, OpenAI, xAI, and OpenRouter

  • Automatic model routing based on model name

  • Usage and cost analytics at http://localhost:3000

  • Works with standard Claude Code env vars

Prerequisites

  • Node.js 18+ and npm

  • API keys for any providers you plan to use

Install and Run the Gateway

git clone https://github.com/ekailabs/ekai-gateway.git
cd ekai-gateway
npm install
npm run dev

Configure Environment

Copy and edit .env with your keys:

Point Claude Code at the Gateway

Claude Code uses ANTHROPIC_* variables. Set the base URL to the gateway and choose a model name; the gateway will route it to the right provider.

Notes

  • Set only one ANTHROPIC_MODEL at a time per session.

  • You can run multiple Claude Code sessions with different models by setting different envs per terminal.

Verify and Monitor

  • Hit the dashboard at http://localhost:3000 to see token usage, costs, and model/provider breakdowns.

  • Check gateway logs in the terminal for request details.

Troubleshooting

  • 401/403 errors: verify the relevant API key is present in .env and the provider allows the chosen model.

  • Connection refused: ensure npm run dev is active and ANTHROPIC_BASE_URL matches the gateway port.

  • Model not found: confirm the model name is supported by its provider and spelled correctly.

Last updated