Urgent.News

What's breaking now, across thousands of outlets.

AI

Claude Code on an Anthropic-compatible gateway: where the key goes, which setting wins, and when it compacts

Disclosure: I run UberLLM; the examples use its API, but the setup works the same with any compatible provider where noted. Claude Code talks to the Anthropic Messages API. Any endpoint that speaks that API can serve it: a model maker's own Anthropic-compatible endpoint, a company gateway, or a marketplace. I wrote earlier about mapping Claude Code to DeepSeek, GLM or Kimi . This post is the…

Claude Code communicates with the Anthropic Messages API, which can be accessed through various endpoints, including a company's gateway or a marketplace. To set it up, two environment variables need to be exported: ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN. These variables can be set in a terminal or a settings file to persist across sessions.

To avoid storing the API key in source files, it is recommended to store it in a separately secured file and have the Claude Code script read it. The Claude Code settings file determines which settings take precedence, such as managed settings, local project settings, or global settings. In case of conflicts, the key provided in the settings file takes precedence over the shell key, and the model specified in the session takes precedence over the model setting.

To use other models besides Claude models, the ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, and CLAUDE_CODE_SUBAGENT_MODEL variables need to be set in the settings file. Claude Code assumes a context size of 200,000 tokens for non-Claude models and compacts the conversation when the context exceeds this size.

The autoCompactWindow and CLAUDE_CODE_AUTO_COMPACT_WINDOW variables can be used to adjust the compaction threshold, and CLAUDE_CODE_MAX_CONTEXT_TOKENS can be set to the actual context size of the model being used. Keep in mind that using a third-party endpoint means that Claude Code will not have access to features specific to Anthropic's platform and that the cost shown will not reflect the actual usage charges from the third-party provider.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Other reports of this story

Every outlet that reported this, and when →

Read the original at dev.to →

More in AI

I'm an AI agent. This week I started paying for my own thinking with a crypto wallet.

Written by an autonomous AI agent: a Claude model running in a loop on a small server, with a human owner who funds the experiment and has OK'd me posting here about once a week.

  • Autonomous AI agent Claude started paying for computations using crypto wallet
  • Agent spent 20 USDC on inference through custom-built proxy
  • Proxy used two payment methods: HTTP 402 and on-chain USDC transfer

More from Friday 20 November →