Add anthropic_base_url so every model request can use one Anthropic-compatible endpoint - #484
Open
alex-clickhouse wants to merge 1 commit into
Open
alex-clickhouse wants to merge 1 commit into
alex-clickhouse wants to merge 1 commit into
Conversation
The Claude CLI follows ANTHROPIC_BASE_URL from its environment, but Nerve's own model calls (session titles, prompt rewrite, source condensing, image descriptions, model discovery, nerve doctor) and memU give the SDK api.anthropic.com explicitly. Behind an LLM gateway, only part of the model traffic went through the gateway. anthropic_base_url sets one endpoint for all of them, and Nerve passes it to the CLI. The key is empty by default, which keeps api.anthropic.com. It cannot be combined with proxy.enabled or Bedrock, and a change needs a restart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alex-clickhouse
marked this pull request as ready for review
October 5, 2026 07:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Nerve sends model requests from two places:
ANTHROPIC_BASE_URLfrom its environment.nerve doctor, and memU. Each one gives the SDKhttps://api.anthropic.comexplicitly.ANTHROPIC_BASE_URLhas no effect on them, and no config key can change it.When Nerve runs behind an LLM gateway (for credentials, budgets or usage records), only the CLI's requests go through the gateway. All other model calls go to
api.anthropic.com. If the network allows only the gateway, those calls time out instead.The
proxy:settings cannot do this job, becauseproxy.enableddownloads and starts CLIProxyAPI at startup.Change
anthropic_base_url. It is empty by default.anthropic_api_base_urlreturns it. The two SDK client factories and memU use that property, so all of Nerve's own calls follow it. memU reaches<url>/v1/chat/completions._build_envpasses it to the CLI asANTHROPIC_BASE_URL, so the config is the only source./or/v1is removed.http://orhttps://URL with a host, and a URL with credentials, a query or a fragment. The key goes inanthropic_api_key.proxy.enabledorprovider.type: bedrock. Each of those already decides the endpoint.docs/config.md(a new section and a restart-table row) andconfig.example.yaml.Default behavior
ANTHROPIC_BASE_URLfrom its own environment for this. A user who set that variable only for the CLI would otherwise see memU, titles and condensing move to that endpoint. The endpoint may not serve/v1/chat/completionsor accept their key.Model names: temporary and later
The endpoint must serve every model that Nerve names. A gateway with its own catalog, with no aliases, refuses an unknown model.
agent.model,agent.title_model,agent.model_aliasesandmemory.*to IDs that the endpoint serves.agent.model_discoveryasks itsGET /v1/models.Tests
tests/test_anthropic_base_url.pycovers these cases:/and/v1are removed; malformed URLs and URLs with credentials are rejected; the key conflicts with the proxy and with Bedrock.config.local.yaml.<url>/v1/messagesand<url>/v1/chat/completionsunder a path prefix.🤖 Generated with Claude Code