Skip to content

feat(anthropic): add Anthropic Messages API endpoints and Claude model profiles - #74

Merged
chaliy merged 4 commits into
mainfrom
claude/anthropic-claude-endpoints-r5jwuf
Jun 28, 2026
Merged

chaliy merged 4 commits into
mainfrom
claude/anthropic-claude-endpoints-r5jwuf

Conversation

@chaliy

@chaliy chaliy commented Jun 28, 2026

Copy link
Copy Markdown
Owner

What

Adds full Anthropic Messages API simulation under the /anthropic provider prefix:

  • POST /anthropic/v1/messages — streaming and non-streaming
  • GET /anthropic/v1/models and GET /anthropic/v1/models/:id

New src/anthropic/ module (types.rs, models.rs, stream.rs) plus src/cli/anthropic_handlers.rs, wired into the router and stats (messages_requests counter, 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 -latest aliases.

Why

LLMSim already simulates OpenAI and OpenResponses; Anthropic was the documented next provider (specs/api-endpoints.md R4). 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

  • Wire-compatible types: string- or block-content messages, system prompts, tools, metadata; tolerant of unknown content blocks (images, documents, thinking).
  • Anthropic SSE event sequence (message_start → content_block_start → content_block_delta → content_block_stop → message_delta → message_stop) with explicit event: lines and no [DONE] sentinel.
  • Anthropic error envelope ({"type":"error","error":{...}}) for injected and scripted errors.
  • Scripted tool_use support (stop_reason: "tool_use", toolu_-prefixed ids).
  • Validated end-to-end against the real Anthropic Python SDK (messages, streaming, models, tool_use), plus TypeScript, Go, curl, and LangChain.
  • Examples (Python, TypeScript, Go, curl, LangChain) now run in the CI examples job; new specs/anthropic-api.md; README/docs/specs/changelog updated.

Risk

  • Low. Purely additive — new module, new routes, one new optional stat field (#[serde(default)]). No existing endpoint or type changed. Existing tests unaffected.
  • What could break: the new CI example steps depend on network (Go go run, uv/npm installs); they run against a local server on :8080 like the existing example steps.

Checklist

  • Tests added or updated (22 unit + 17 integration tests; smoke-test extended)
  • Backward compatibility considered (additive only; new stat field defaults)

Generated by Claude Code

chaliy added 4 commits June 28, 2026 02:08
…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.
@chaliy
chaliy merged commit 62fda23 into main Jun 28, 2026
11 checks passed
@chaliy
chaliy deleted the claude/anthropic-claude-endpoints-r5jwuf branch June 28, 2026 23:58
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