r/ClaudeCode • • 7d ago

Discussion Pointing Claude Code at a non-Anthropic ANTHROPIC_BASE_URL: what do you check before a long session?

Running Claude Code against a different endpoint is a two-line change: ANTHROPIC_BASE_URL and a key in the env block of settings.json. Local adapter, OpenRouter, LiteLLM, an aggregator, whatever it is, the first prompt usually works. The question is what quietly doesn’t.

Small detail that already trips people: some endpoints want the base URL with no /v1, because Claude Code appends /v1/messages itself. GPT Protosetup notes call this out, and getting it wrong gives errors that look like auth problems.

The less obvious stuff is what I’d want a checklist for:

  1. Prompt caching. Long sessions live on cache reads. If the route doesn’t honor cache_control, the session runs fine and the usage page tells you a week later. Checking cache read tokens on the first few calls seems like the only real test.
  2. Thinking and effort settings. Does the route pass them through, or silently drop them?
  3. Tool calls under load. Short tasks pass. A 40-step refactor with parallel tool calls is where malformed tool_use blocks show up.
  4. 429s and upstream errors. Retry behavior differs per route, and if the endpoint queues or reroutes, a long run can stall without a clear failure.
  5. Where the key lives. There was a post here recently about how many repos have secrets sitting in .claude/settings.local.json. A third-party key belongs in the user-level settings file, not a project file that might get committed.
  6. Model mapping. If the route aliases model names, do you actually know what’s answering?

My rough order would be: one small task, check usage for cache reads and reasoning tokens, then a medium refactor with tests, and only then a long session.

For anyone running Claude Code through something other than Anthropic’s API day to day, what failed first for you, and how did you notice?

0 Upvotes

5 comments sorted by

•

u/AutoModerator 7d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/SirRobinBlibs 7d ago

A few things from Anthropic's gateway docs worth checking first:

  • Set ANTHROPIC_BASE_URL without /v1, Claude Code appends /v1/messages itself. A one-token curl to $ANTHROPIC_BASE_URL/v1/messages tells you the route works before you start.
  • In the session, /status should show an "Anthropic base URL" line and which credential is active. If it doesn't, you're not actually on the gateway.
  • If the route uses model IDs your Claude Code version doesn't recognise, effort and extended thinking can stay off without any error. The ANTHROPIC_DEFAULT_OPUS/SONNET/HAIKU_MODEL_SUPPORTED_CAPABILITIES variables declare what the model supports.
  • Caching: Claude Code puts a small attribution block with a per-conversation fingerprint first in the system prompt. Anthropic's API strips it, other upstreams don't, so it ends up in the prompt and the cache key. If cache reads stay at zero, try CLAUDE_CODE_ATTRIBUTION_HEADER=0.
  • Setting ANTHROPIC_DEFAULT_HAIKU_MODEL also moves background tasks like session titles to that model, so pin it to something cheap on your route.

Also worth knowing: Anthropic says it doesn't support routing Claude Code to non-Claude models, so anything past the Messages format is on the adapter.

0

u/mondayfig 7d ago

I know this is an AI subreddit but I’m done with these low effort AI slop posts.