Skip to main content

Claude Code custom API endpoint: quick answer

A Claude Code custom API endpoint must be Anthropic-compatible. In this documentation, Claude Code uses https://bettertoken.ai. Do not add /v1. For general Claude API access, available models, and ways to get started, use the BetterToken Claude API page. This FAQ only covers using an existing BetterToken API key with Claude Code through its Base URL and environment variables; it does not duplicate the general API overview. The API Key authenticates the request. The Base URL tells Claude Code where to send model requests. Both must belong to the same provider and protocol. With the Claude provider, Claude Code usually needs ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN. With the GPT provider, you also need Claude Code model mappings from the setup guide.

When this matters

  • You want Claude Code to use a custom API gateway
  • You have an API Key but are unsure which Base URL to use
  • Claude Code reports an authentication or endpoint error
  • You are choosing between https://bettertoken.ai and https://bettertoken.ai/v1
  • You need to understand Claude and GPT providers

Key concepts

Choose the setup path by provider. Claude provider:
The GPT provider needs additional Claude Code model mappings. Use the full Claude Code setup guide instead of copying only this short example. After editing the config, restart Claude Code and send a short test message. If it fails, first check whether the Base URL was accidentally set to https://bettertoken.ai/v1.

Common mistakes

  • Adding /v1 to the Claude Code Base URL.
  • Changing the API Key but leaving requests pointed at the default endpoint.
  • Treating a GPT provider model ID as a Claude provider model.
  • Putting an OpenAI-compatible endpoint into Claude Code’s Anthropic-compatible fields.
  • Defining old environment variables in a shell profile that override the new config.

About BetterToken

BetterToken provides two endpoint types: the Anthropic-compatible https://bettertoken.ai for Claude Code and the OpenAI-compatible https://bettertoken.ai/v1 for Codex and external tools. This lets you manage API Keys, balance, and usage history in one dashboard, but it does not change Claude Code’s requirement for Anthropic-compatible request formatting.

References