Skip to content

feat(claude): support custom ANTHROPIC_BASE_URL and proxy endpoints - #127

Closed
Totopo27 wants to merge 1 commit into
Louis-CFM:mainfrom
Totopo27:feat/custom-anthropic-base-url
Closed

Totopo27 wants to merge 1 commit into
Louis-CFM:mainfrom
Totopo27:feat/custom-anthropic-base-url

Conversation

@Totopo27

@Totopo27 Totopo27 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds support for configuring a custom Anthropic API base URL via the ANTHROPIC_BASE_URL environment variable or directly in the Claude Settings view, enabling users to route requests through self-hosted proxies, LiteLLM, Ollama proxies, or enterprise gateways.

Closes #26

Motivation & Root Cause

The Anthropic messages endpoint was hardcoded to https://api.anthropic.com/v1/messages across both the Windows backend and macOS service. Users running third-party proxies, local model gateways, or custom network setups could not direct Mochi's chat queries to their custom endpoints.

Key Changes

  • windows/src-tauri/src/claude.rs:
    • Added resolve_endpoint(custom) helper that normalizes custom base URLs (appending /v1/messages if omitted, respecting explicit /messages or /v1 paths, and falling back to ANTHROPIC_BASE_URL then the default Anthropic endpoint).
    • Updated send and call to dispatch to the resolved endpoint.
    • Added unit test covering standard proxy URL formats.
  • windows/src-tauri/src/settings.rs & windows/src-tauri/src/lib.rs:
    • Added optional anthropic_base_url to Settings.
    • Forwarded custom base URL from settings into claude::send.
  • windows/src/core/state.ts & windows/src/settings/main.ts:
    • Added "Base URL" configuration input row under the Claude settings section.
  • NotchBuddy/Sources/App/ClaudeService.swift:
    • Updated endpoint and fetchModels on macOS to inspect ANTHROPIC_BASE_URL environment variable when present.

Verification

  • cargo test claude passed (including endpoint_resolution_handles_various_url_formats).
  • npx tsc --noEmit clean on the frontend.

@Totopo27

Totopo27 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

I created a more surgical, env-only alternative in #206 to resolve #180. If UI settings aren't desired yet, feel free to close this in favor of #206.

@Totopo27

Totopo27 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of the upstream solution implemented in #307 / Windows v0.2.0 via COUCOU_ANTHROPIC_BASE_URL. Thanks @Louis-CFM!

@Totopo27 Totopo27 closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modify ANTHROPIC_BASE_URL

1 participant