Skip to main content

anthropic_mock_wrapper

A lightweight wrapper around the Anthropic Python client for testing purposes.

Save money on your Anthropic API usage by mocking responses when your API key is prefixed with TEST_.

Installation

You can install the anthropic_mock_wrapper package using pip:

pip install anthropic_mock_wrapper
from anthropic_mock_wrapper import AnthropicMockWrapper

Initialize the client

client = AnthropicMockWrapper(api_key="TEST_your_api_key_here")

Use the client to interact with Anthropic's API

response = client.complete(
prompt="Hello, world!",
model="claude-2",
max_tokens_to_sample=100
)
print(response)
from anthropic_mock_wrapper import AnthropicMockWrapper
# Initialize the testable client
testable_client = AnthropicMockWrapper(api_key="test_key")
#Set a mock response
testable_client.set_mock_response({
"completion": "This is a mock response",
"stop_reason": "stop_sequence",
"model": "claude-2"
})
# Use the client in your tests
response = testable_client.complete(
prompt="Test prompt",
model="claude-2",
max_tokens_to_sample=100
)
assert response["completion"] == "This is a mock response"

Build

python -m build

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

This is an unofficial Mocker and is not affiliated with or endorsed by Anthropic. Use at your own risk.

Release files for anthropic-mock-wrapper 0.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anthropic-mock-wrapper 0.2.10
File Size Uploaded
anthropic_mock_wrapper-0.2.10.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anthropic-mock-wrapper 0.2.10
File Interpreter ABI Platform
anthropic_mock_wrapper-0.2.10-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / anthropic_mock_wrapper-0.2.10.tar.gz

Download URL anthropic_mock_wrapper-0.2.10.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
be76fa53cac39bdb9ece2b2aed67837d56aaae5c8ea3383fef557a16f84f2a16
BLAKE2b-256 checksum
How to use checksums
2ebc0f0c64c450235836020f1580d4a92b8fa5d80ea3db3b6bd4735e0b2e430c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / anthropic_mock_wrapper-0.2.10-py3-none-any.whl

Download URL anthropic_mock_wrapper-0.2.10-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55820c0e278075df06a2b97905ef7be0b73c261ab2f765d99cae636d383dec1d
BLAKE2b-256 checksum
How to use checksums
0328bedfa53d901966325486e12ecdf75846499e3d1263f443b6f0eaaafb2223
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.2.10 This release

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page