Setup · 7 min read

How to use Claude Code with a custom API endpoint

Claude Code is powerful, but you should not have to rewrite your workflow every time you change providers. If your gateway speaks the Anthropic Messages API, the setup is just a few environment variables.

1. Get an API key

Create a key with your provider and keep it in your shell environment. Never paste a live key into a project file or commit it to git.

2. Point Claude Code at the endpoint

export ANTHROPIC_API_KEY="your_api_key"
export ANTHROPIC_BASE_URL="https://api.example.com"
claude

The important detail is the base URL: it should be the provider's API root, not a dashboard URL. The gateway should expose POST /v1/messages and return Anthropic-style streaming events.

3. Verify the three things that usually break

When a custom endpoint is worth it

A compatible gateway is useful when you need one stable endpoint across providers, clearer cost control, or a lower-cost route for development work. Keep a reliable fallback for production-critical tasks.

Related guides

Connect Claude Code in minutes

Kintio provides an Anthropic-compatible endpoint for Claude Code and other AI coding tools.

Try Kintio →