Skip to content

feat(anthropic): real Anthropic backend, env-gated in CLI#18

Merged
MoonZagallo merged 1 commit into
WitnexCorp:mainfrom
MoonZagallo:feat/anthropic-backend
Jun 19, 2026
Merged

feat(anthropic): real Anthropic backend, env-gated in CLI#18
MoonZagallo merged 1 commit into
WitnexCorp:mainfrom
MoonZagallo:feat/anthropic-backend

Conversation

@MoonZagallo

Copy link
Copy Markdown
Contributor

Summary

A real Anthropic Claude backend, selected at runtime by env var.

  • New crate witnex-anthropic: AnthropicBackend implements LlmBackend over the Messages API via reqwest. LlmRequest (which already mirrors the API shape) serializes directly as the request body; response text blocks concatenate into LlmResponse.
  • CLI demo summarize now runs on a Tokio runtime and picks the backend: AnthropicBackend when ANTHROPIC_API_KEY is set, else the offline MockBackend (prints which ran). No key → behaves exactly as before.
  • Offline unit tests assert the serialized request matches the Messages API body.

Usage

# offline (unchanged)
witnex demo summarize "..."            # backend: mock

# real Claude
ANTHROPIC_API_KEY=sk-ant-... witnex demo summarize "..."   # backend: anthropic

Notes

  • TLS: reqwest default (native-tls); ubuntu CI ships the OpenSSL dev libs.
  • reqwest does not build on native Windows in this dev env, so this is validated by Linux CI (full cargo clippy/test --workspace), not locally. No live API call is made in tests (no token spend).

- new crate witnex-anthropic: AnthropicBackend implements LlmBackend over
  the Messages API (reqwest). LlmRequest serializes directly as the request
  body; response text blocks -> LlmResponse.
- CLI: run on a Tokio runtime; use AnthropicBackend when ANTHROPIC_API_KEY
  is set, else the offline MockBackend. Prints which backend ran.
- offline unit tests: request body matches the Messages API shape.

Note: reqwest does not build on native Windows here; validated via Linux CI.
@MoonZagallo MoonZagallo merged commit 51b355f into WitnexCorp:main Jun 19, 2026
2 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