Skip to content

feat(inference): add native Anthropic (Claude) provider#18

Merged
johnford2002 merged 6 commits into
mainfrom
feat/native-anthropic-provider
Jun 15, 2026
Merged

feat(inference): add native Anthropic (Claude) provider#18
johnford2002 merged 6 commits into
mainfrom
feat/native-anthropic-provider

Conversation

@johnford2002

@johnford2002 johnford2002 commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Fork merge of the native Anthropic provider. Upstream contribution PR: karakeep-app#2890 (same change, based on upstream/main).

Summary

Adds a first-class Anthropic (Claude) inference provider, selected by ANTHROPIC_API_KEY, using the official @anthropic-ai/sdk Messages API — instead of routing Claude through Anthropic's OpenAI-compatibility endpoint (which ignores strict/json_schema enforcement, so structured tagging output isn't guaranteed).

What it does

  • New AnthropicInferenceClient in packages/shared/inference.ts; selected in InferenceClientFactory.build() when ANTHROPIC_API_KEY is set (precedence: OpenAI → Anthropic → Ollama).
  • Text + image inference for auto-tagging and summarization, with native Structured Outputs (output_config.format json_schema) for guaranteed schema conformance.
  • Defaults to claude-haiku-4-5 (override via INFERENCE_TEXT_MODEL / INFERENCE_IMAGE_MODEL).
  • New env vars ANTHROPIC_API_KEY + optional ANTHROPIC_BASE_URL; docs updated. Purely additive.

Limitations

  • No embeddings (Anthropic has none) — generateEmbeddingFromText throws a clear error; semantic search needs a separate embedding provider.

Test plan

  • packages/shared/inference.test.ts (8 tests) green; pnpm format/lint/typecheck/build pass; @karakeep/shared suite (111) green.

🤖 Generated with Claude Code

@johnford2002 johnford2002 merged commit 1df12b0 into main Jun 15, 2026
5 checks passed
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.

1 participant