Integration

Claude Code and the Anthropic SDK

BaseLLM also offers an endpoint in the Anthropic Messages API format: POST /api/v1/messages. Claude Code and apps on the Anthropic SDK work through BaseLLM by changing the address. Model rules, aliases, limits, budgets, data masking and logs apply as on the OpenAI-compatible endpoint.

How it works

When the request goes to an Anthropic model, the body goes on to Anthropic as the client sent it. BaseLLM changes only what its own rules call for: the model name, the connection's system prompt, the data mask and the policy's max_tokens cap. Thinking, images, documents, web search and Claude Code's own cache settings work as they are. BaseLLM adds a few milliseconds.

When the first model to answer is another provider's (e.g. an alias points to an OpenAI model), the request is turned into a chat request, and the limits in the table below apply.

For the notice to give employees before rolling it out in the company, see Employee privacy notice for Claude Code (sample).

Connecting Claude Code

Set these variables on the developer's machine:

VariableValue
ANTHROPIC_BASE_URLhttps://<BaseLLM address>/api
ANTHROPIC_API_KEYThe project's API key (sk-ffm-...)
ANTHROPIC_MODELOptional; e.g. claude-sonnet-4-5 or an alias of the project
ANTHROPIC_DEFAULT_HAIKU_MODELOptional; the small model Claude Code uses for background work
ANTHROPIC_CUSTOM_HEADERSOptional; "X-FFM-User: ayse" for per-user limits

The key can be sent in the x-api-key header or as Authorization: Bearer.

Company-wide rollout

The Claude Code tab on the project page in the panel prepares the managed-settings.json file to roll out to developer machines. The file pins BaseLLM's address and allows connecting to BaseLLM only (allowedProviders, Claude Code 2.1.285 or later). It points the Sonnet, Opus and Haiku names at the project's Claude models. By default it turns off side traffic to Anthropic (statistics, error reports, feedback). The file goes under /Library/Application Support/ClaudeCode/ on macOS, C:\Program Files\ClaudeCode\ on Windows and /etc/claude-code/ on Linux, or is rolled out by MDM. Blocking api.anthropic.com for developer machines on the network makes the rule final.

Browser sign-in

With browser sign-in turned on in the tab, there are no keys to hand out to developers. A key helper script (apiKeyHelper) is rolled out with the file. When Claude Code opens, the helper opens BaseLLM's sign-in page in the browser. The developer signs in with the company account (LDAP / AD; a BaseLLM account without a directory) and gets a 12-hour login token. When it runs out, Claude Code asks for a sign-in again.

  • The project can name the AD groups that may sign in; with none named, everyone in the directory may.
  • On requests with a login token, the end user is the developer who signed in. Per-user budgets, limits and logs work with that identity; the X-FFM-User header is ignored.
  • A login token only works on the endpoints Claude Code uses (Messages API, count_tokens, the model list).
  • An admin can sign a developer out from the tab; the token stops working within 30 seconds.

Subscription mode (Team / Enterprise)

When developers keep signing in with the company's claude.ai subscription, requests go straight to Anthropic and BaseLLM is not in between. In this mode protection runs on the developer's machine, through Claude Code hooks. With "Subscription" chosen on the setup tab, the generated managed-settings.json:

  • Has BaseLLM scan every prompt; a prompt with personal data is not sent and the developer is warned (a hook cannot change a prompt, only stop it).
  • Masks file, command and MCP output with the project's personal data policy before the model reads it.
  • Forbids reading .env, secrets/, *.pem and *.key; only the admin's hooks run, and the action stops when BaseLLM cannot answer (Claude Code 2.1.295+).
  • Sends usage to BaseLLM over OpenTelemetry: sessions, requests, tokens, estimated cost, lines and commits per person; no prompt or answer text.
  • Optionally allows sign-in with the company's Anthropic organization only; on the network, the anthropic-allowed-org-ids header can shut out personal accounts too (Enterprise).

The hooks come with a guard key that can only scan; when an admin creates a new key, the old one stops working. On a subscription, the desktop app has no such protection for Chat and Cowork; use API key mode for full protection on the desktop.

What the project needs

  • Tool support must be on. Claude Code sends tool definitions with every request; with it off the request gets tools_not_enabled.
  • The model names Claude Code asks for must resolve in the project. Turn on model choice on an Anthropic connection with a pattern such as claude-*, or define aliases. With model choice off the name is ignored and the project's first model answers.
  • For per-user budgets and limits, each developer sends their own X-FFM-User; on a project that requires signed user IDs the signature is needed too.

What is and isn't supported

FieldTo an Anthropic modelTo another provider
system, messages, max_tokensAs sentSupported
tools, tool_choiceAs sentSupported; disable_parallel_tool_use is passed on
streamAnthropic's events as they comeTurned into Anthropic events
temperature, top_p, stop_sequencesAs sentSupported; at most 4 stop sequences
thinkingSupported; signed blocks go back unchangedNot supported; left out of the history
Image and document blocksSupportedNot passed on; a short note takes their place
Server tools (web search)SupportedNot offered to the model
cache_controlThe client's settings applyBaseLLM sets the cache itself
anthropic-beta headerPassed onIgnored
POST /api/v1/messages/count_tokensAnthropic's own countAn estimate (≈ 4 characters = 1 token)

For requests to an Anthropic model, a fallback is picked among the Anthropic models in the project's chain; the chain's other providers are not tried for these requests, since thinking blocks and Anthropic-only content are not valid there. Conversation memory, the response cache and smart routing are off on this path: Claude Code keeps the conversation itself, and they would change it.

Data masking cannot read text inside images; images are passed on as they are. Thinking blocks are left alone: Anthropic signs them and refuses a changed one. The model only ever saw masked text, so the blocks hold no real values.

Errors

Errors come back in Anthropic's shape: type: error and error.type (invalid_request_error, authentication_error, rate_limit_error, api_error...). BaseLLM's own error code is in error.code, e.g. budget_exceeded, api_key_expired, model_not_allowed.