feat(anthropic): add Anthropic Messages API endpoints and Claude model profiles - #74
Merged
Merged
Conversation
…l profiles
Implements the Anthropic Messages API simulation so the official Anthropic SDKs
work when pointed at {base_url}/anthropic.
- POST /anthropic/v1/messages (streaming + non-streaming)
- GET /anthropic/v1/models and GET /anthropic/v1/models/:id
- Realistic Claude model profiles (models.dev) using the real Anthropic API
model IDs (claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5,
claude-fable-5, ...) plus dated-snapshot and -latest aliases
- Anthropic SSE event sequence (message_start, content_block_delta,
message_stop) with no [DONE] sentinel
- Anthropic error envelope and scripted tool_use support
- messages_requests stat counter (HTTP + TUI)
- Integration tests, multi-stack examples (Python, TypeScript, Go, curl,
LangChain), and specs/anthropic-api.md
…; expand README
- CI `examples` job now runs the Anthropic Python (anthropic_client,
anthropic_langchain), TypeScript, Go, and curl examples against the server.
- Add `@anthropic-ai/sdk` to examples/node deps; add Go toolchain setup.
- Commit examples/go/{go.mod,go.sum} so the Go example runs without manual
setup; ignore the compiled binary.
- README: streaming-format note, Anthropic SDK quick-start snippet, real
Anthropic model-ID note, and an examples pointer.
…de-endpoints-r5jwuf # Conflicts: # .github/workflows/ci.yml # examples/README.md # examples/node/package-lock.json # examples/node/package.json
The doc CI job runs cargo doc with -D warnings; rustdoc's bare-urls lint rejected two bare URLs in /// comments. Wrap them in <> to make them automatic links.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds full Anthropic Messages API simulation under the
/anthropicprovider prefix:POST /anthropic/v1/messages— streaming and non-streamingGET /anthropic/v1/modelsandGET /anthropic/v1/models/:idNew
src/anthropic/module (types.rs,models.rs,stream.rs) plussrc/cli/anthropic_handlers.rs, wired into the router and stats (messages_requestscounter, HTTP + TUI).Realistic Claude model profiles sourced from models.dev / the Anthropic docs, using the real Anthropic API model IDs (
claude-opus-4-8,claude-sonnet-4-6,claude-haiku-4-5,claude-fable-5, the Opus/Sonnet 4.x line, Claude 3.x) with dated-snapshot and-latestaliases.Why
LLMSim already simulates OpenAI and OpenResponses; Anthropic was the documented next provider (
specs/api-endpoints.mdR4). This lets teams load-test and reproduce Claude-integrated apps — including the official Anthropic SDKs (Python, TypeScript, Go) — without API cost or running a model.How
message_start→content_block_start→content_block_delta→content_block_stop→message_delta→message_stop) with explicitevent:lines and no[DONE]sentinel.{"type":"error","error":{...}}) for injected and scripted errors.tool_usesupport (stop_reason: "tool_use",toolu_-prefixed ids).examplesjob; newspecs/anthropic-api.md; README/docs/specs/changelog updated.Risk
#[serde(default)]). No existing endpoint or type changed. Existing tests unaffected.go run,uv/npm installs); they run against a local server on :8080 like the existing example steps.Checklist
Generated by Claude Code