Claude (Anthropic) API emulator – LocalStack extension
Project description
claude-local
A lightweight local emulator for the Anthropic Claude API, built for testing and local development.
Install it as a LocalStack extension to intercept Claude API calls within your LocalStack-powered test environment — no API key, no network, no credits consumed.
Quick start
LocalStack extension
# Install into a running LocalStack instance
pip install localstack-claude
localstack extensions install localstack-claude
# Or dev mode
make ls-dev
Then point your SDK at:
ANTHROPIC_BASE_URL=http://claude.localhost.localstack.cloud:4566
ANTHROPIC_API_KEY=test-key
API coverage
| Endpoint | Status |
|---|---|
POST /v1/messages |
✅ |
POST /v1/messages (streaming) |
✅ |
GET /v1/models |
✅ |
GET /v1/models/{id} |
✅ |
POST /v1/messages/batches |
🔜 |
Supported models
All current Claude models are recognized (by versioned ID or alias):
claude-opus-4-7/claude-opus-4-7-20250514claude-sonnet-4-6/claude-sonnet-4-6-20250514claude-haiku-4-5/claude-haiku-4-5-20251001claude-3-5-sonnet-20241022,claude-3-5-haiku-20241022claude-3-opus-20240229,claude-3-sonnet-20240229,claude-3-haiku-20240307
Response behaviour
The emulator does not call a real LLM. It returns a deterministic response that can be configured:
# Environment variable (set before startup)
CLAUDE_LOCAL_RESPONSE="My custom response"
# Runtime override (POST to the control plane)
curl -s -X POST http://localhost:5002/_claude/config \
-H "Content-Type: application/json" \
-d '{"response": "My custom response"}'
Tool use
Force a tool call response by sending the X-Claude-Local-Tool: <tool_name> header,
or by setting tool_choice to {"type": "any"} in the request.
Snapshot testing
claude-local ships with snapshot tests that record real Anthropic API responses and
verify the emulator produces structurally identical output (using
localstack-snapshot).
# Install deps
pip install -e ".[dev,snapshot]"
# Record real API responses
ANTHROPIC_API_KEY=sk-ant-... pytest -m snapshot --snapshot-update
# Verify emulator parity (no key needed)
pytest -m snapshot
Development
make install-dev # install with dev deps
make test # run all tests
make run # start emulator on port 5002
make lint # ruff check
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file localstack_claude-0.1.0.tar.gz.
File metadata
- Download URL: localstack_claude-0.1.0.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
389678907f42f8f2bcd0cbaceb7cfe596cd12f9bc27bb4526f59344f44a3e624
|
|
| MD5 |
6311a4f561e98b72c76207541bfd3e16
|
|
| BLAKE2b-256 |
e34b4e29f009e109a7d1d9875f0a1d09fda81dba6875dfc4a618a013333eed55
|
File details
Details for the file localstack_claude-0.1.0-py3-none-any.whl.
File metadata
- Download URL: localstack_claude-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd14a2f1e1b28377f14a7984ccfa8858fe744272a65472d47b18d9ea9e439364
|
|
| MD5 |
b1557ee475a11b6137d7919e889e85b9
|
|
| BLAKE2b-256 |
751a3227b5b7eeae3d042add39141d4496d2d4875cc0e0a8bea980c5286c1c82
|