Skip to content

feat(claude): support custom Anthropic base URL via environment variable - #206

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

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

Conversation

@Totopo27

@Totopo27 Totopo27 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Resolves #180.

What it does

Allows pointing the Claude API client on Linux/Windows to a custom endpoint or gateway (such as LiteLLM, corporate proxies, or local relays) by checking \COUCOU_ANTHROPIC_BASE_URL\ (or standard \ANTHROPIC_BASE_URL), falling back to the public endpoint when neither is set.

Trailing slashes are automatically trimmed.

Changes

  • \windows/src-tauri/src/claude.rs: check \COUCOU_ANTHROPIC_BASE_URL\ and \ANTHROPIC_BASE_URL\ before falling back to \https://api.anthropic.com/v1/messages\.
  • Unit tests validating default fallback, environment override, and trailing slash handling.

Verification

\cargo test --manifest-path windows/src-tauri/Cargo.toml\ passes cleanly.

JhoanG956 pushed a commit to JhoanG956/coucou that referenced this pull request Oct 7, 2026
… name

Groundwork for the Mac's chat providers on Windows and Linux, with the
Claude chat brought to parity first:

- chat.rs holds the conversation for every provider: in the wire format of
  the provider that answered last, and as plain text turns. A turn with
  another provider rebuilds its history from the plain turns, so Claude's
  web search blocks are never sent anywhere else. Only a successful turn is
  recorded, and an answer that lands after "New chat" is dropped.
- Claude's answer keeps every text block, joined as is (Mac Louis-CFM#67, commit
  0a633f9): citations no longer get a line break in mid-sentence.
- The system prompt asks for light Markdown, as on the Mac, and greets the
  user by their first name when the account has one worth using (Mac Louis-CFM#154,
  same rules as UserIdentity.swift): the Windows display name or the Linux
  GECOS full name; login handles are ignored.
- COUCOU_ANTHROPIC_BASE_URL sends the Claude chat through an
  Anthropic-compatible gateway (issue Louis-CFM#180). It is a base URL
  (/v1/messages is added when missing), must be https (http only to this
  computer), and only that variable is read: Claude Code's
  ANTHROPIC_BASE_URL could hand the user's key to a proxy they never chose.
  The gateway's host, never the key, is logged once.
- Every answer is read with a size ceiling (net.rs), and requests to this
  computer skip any system proxy.
- chat_models lists the models on the Anthropic account, for the picker.

Based on Louis-CFM#206 by @Totopo27 (custom Anthropic base URL), reduced to
COUCOU_ANTHROPIC_BASE_URL and tested without touching the environment.

Co-authored-by: Totopo27 <35828647+Totopo27@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner

Thank you! Fixed #180 in Coucou for Windows 0.2.0 (https://github.com/Louis-CFM/coucou/releases/tag/windows-v0.2.0), based on this PR (credited). Changes: only COUCOU_ANTHROPIC_BASE_URL is read — Claude Code's ANTHROPIC_BASE_URL often points at a proxy, and Coucou would silently send the Anthropic key there — it accepts a base URL, and requires https except on this machine. Details in #307.


Generated by Claude Code

@Louis-CFM Louis-CFM closed this Oct 7, 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.

Linux/Windows chat client hardcodes api.anthropic.com — no way to point it at a gateway

2 participants