anthropic.twins.la
A digital twin of the Anthropic Messages API.
What is this?
A high-fidelity digital twin of the public Anthropic Messages
API. The twin returns synthetic, deterministic responses that
match the real API's shape exactly — consumer SDKs
(anthropic, etc.) work without modification.
Use it to prototype, run CI, or test integrations without burning live credits or hitting quotas.
Supported scenarios
messages-api—POST /v1/messages(full + SSE streaming),POST /v1/messages/count_tokens,GET /v1/models[/{id}], plusprompt-caching-2024-07-31andextended-thinkingbeta headers.
How to use it
Cloud: Mint an api key via
POST /_twin/accounts on
https://anthropic.twins.la, then point your
Anthropic SDK at the twin's base URL.
Local: Install with
pip install twins-anthropic-local and run a local
instance on any port. Same API, same behaviour, your machine.
For agents
Copy this into your agent's system prompt, tool configuration, or
CLAUDE.md. Also available as plain text at
/_twin/agent-instructions.
# Anthropic Messages API Twin — anthropic.twins.la
A digital twin of the public Anthropic Messages API. Synthetic responses
only — the twin never calls api.anthropic.com. The shape matches the
real API verbatim, so consumer SDKs work without modification.
## Authentication
Twin Plane: HTTP Basic (tenant_id:tenant_secret)
Bootstrap a tenant first:
POST /_twin/tenants -> {tenant_id, tenant_secret}
Twin Plane Admin: Bearer token (set by deployment owner)
Authorization: Bearer <admin_token>
Or: X-Twin-Admin-Token: <admin_token>
Provider (data plane):
x-api-key: sk-ant-twin-... (mint via POST /_twin/accounts)
anthropic-version: 2023-06-01 (any value accepted)
Optional:
anthropic-beta: prompt-caching-2024-07-31
anthropic-beta: extended-thinking-2025-01-15
## Key Endpoints
Twin Plane (no auth):
GET /_twin/health
GET /_twin/scenarios
GET /_twin/settings
GET /_twin/references
GET /_twin/agent-instructions
POST /_twin/tenants
Twin Plane (Basic tenant_id:tenant_secret):
POST /_twin/accounts — kind=api_key — returns {api_key} once
GET /_twin/accounts — list api keys (masked)
GET /_twin/messages — message history for this tenant
GET /_twin/logs
POST /_twin/feedback
GET /_twin/feedback
Provider (x-api-key + anthropic-version):
POST /v1/messages — full or SSE streaming via stream:true
POST /v1/messages/count_tokens
GET /v1/models
GET /v1/models/<model_id>
## Quick Start (local)
1. pip install twins-anthropic twins-anthropic-local
python -m twins_anthropic_local
2. Bootstrap a tenant:
curl -X POST http://localhost:8080/_twin/tenants \
-H "Content-Type: application/json" \
-d '{"friendly_name": "Dev"}'
# -> { tenant_id, tenant_secret }
3. Mint an api key:
curl -X POST http://localhost:8080/_twin/accounts \
-u "TENANT_ID:TENANT_SECRET" \
-H "Content-Type: application/json" \
-d '{"kind":"api_key","friendly_name":"Demo Key"}'
# -> { api_key, api_key_id, ... }
4. Call the Messages API:
curl -X POST http://localhost:8080/v1/messages \
-H "x-api-key: $API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-3-5-sonnet-latest","max_tokens":64,
"messages":[{"role":"user","content":"hi"}]}'
# -> { id, type:"message", role:"assistant", content:[{type:"text",...}], ... }
## Reference
GitHub: https://github.com/twins-la/anthropic
Project overview: https://twins.la
All twins: https://github.com/twins-la/twins-la