Add Anthropic API support (#51)
authorStefan Gasser <redacted>
Tue, 20 Jan 2026 22:06:58 +0000 (23:06 +0100)
committerGitHub <redacted>
Tue, 20 Jan 2026 22:06:58 +0000 (23:06 +0100)
commitf083f542336ea42f9eaa9fbc2d87e0719dfe9400
treea97431affa75e636e4930173b90d9648a84c5181
parent104b813b965d8dd5566209a295a92243e21f41f0
Add Anthropic API support (#51)

* Add Anthropic provider

- Add /anthropic/v1/messages endpoint with full API compatibility
- Support OAuth tokens from Claude Code for subscription users
- Provider-agnostic text extraction for PII/secrets masking
- Support streaming and non-streaming responses
- Remove unused cloud provider health checks (only local services need them)

* Add Anthropic provider documentation

- Update README and introduction to mention Anthropic support
- Add Claude Code and Anthropic SDK to integrations
- Document Anthropic provider config with OAuth support
- Create separate API reference pages for OpenAI and Anthropic
- Update navigation structure

* Improve provider error messages in logs

- Add errorMessage getter to parse OpenAI/Anthropic error formats
- Log parsed error message instead of generic "Provider error"

* Update docs wording for multi-provider support

- Clarify OpenAI and Anthropic APIs with compatible providers
- Note Anthropic endpoint is mask mode only (route mode coming)

* Add route mode support for Anthropic endpoint

- Add callLocalAnthropic function for Ollama's Anthropic API
- Update Anthropic route to support route mode with local provider
- Update docs to reflect both mask and route mode support

* Add Anthropic brand color to dashboard provider badges

* Fix duplicate /v1 prefix in Anthropic proxy wildcard handler

The path variable already contains the full path after stripping the
/anthropic prefix (e.g., /v1/messages or /api/foo). Adding /v1 again
caused double prefixes for v1 paths and incorrect paths for non-v1
endpoints like /api/event_logging/batch.

* Add role field to Anthropic extractor for scan_roles filtering

* Remove OAuth token reading, use transparent header forwarding

- Delete oauth.ts - no longer read tokens from local storage
- Simplify client.ts to forward all auth headers transparently
- Simplify anthropic.ts wildcard handler
- Add Claude Code system prompt to default whitelist
- Whitelist merges user entries with default (not replaces)

* Simplify wildcard proxies to fully transparent passthrough

* Fix wildcard proxy host header forwarding

* Update documentation: simplify intro, remove OAuth docs, add Anthropic to architecture

* Improve documentation: simplify intro, update API links, remove redundant api_key exports
31 files changed:
CLAUDE.md
README.md
docs/api-reference/anthropic.mdx [new file with mode: 0644]
docs/api-reference/openai.mdx [moved from docs/api-reference/chat-completions.mdx with 95% similarity]
docs/concepts/mask-mode.mdx
docs/concepts/route-mode.mdx
docs/configuration/providers.mdx
docs/integrations.mdx
docs/introduction.mdx
docs/mint.json
src/config.ts
src/index.ts
src/masking/extractors/anthropic.test.ts [new file with mode: 0644]
src/masking/extractors/anthropic.ts [new file with mode: 0644]
src/providers/anthropic/client.ts [new file with mode: 0644]
src/providers/anthropic/stream-transformer.test.ts [new file with mode: 0644]
src/providers/anthropic/stream-transformer.ts [new file with mode: 0644]
src/providers/anthropic/types.ts [new file with mode: 0644]
src/providers/errors.test.ts [new file with mode: 0644]
src/providers/errors.ts
src/providers/local.ts
src/providers/openai/client.ts
src/routes/anthropic.test.ts [new file with mode: 0644]
src/routes/anthropic.ts [new file with mode: 0644]
src/routes/health.ts
src/routes/info.ts
src/routes/openai.test.ts
src/routes/openai.ts
src/routes/utils.ts
src/services/logger.ts
src/views/dashboard/page.tsx
git clone https://git.99rst.org/PROJECT