Pre-release
This release is a pre-release and may not be stable for production use.
elizaos-plugin-anthropic
Python implementation of the Anthropic Claude API client for elizaOS.
Features
- Text generation with Claude models
- Structured JSON object generation
- Strong types with Pydantic models
- Fail-fast error handling
- Async/await support with httpx
Installation
pip install elizaos-plugin-anthropic
Usage
Text Generation
import asyncio
from elizaos_plugin_anthropic import AnthropicClient, AnthropicConfig, TextGenerationParams
async def main():
config = AnthropicConfig.from_env()
async with AnthropicClient(config) as client:
# Simple prompt
response = await client.generate_text_large("What is the meaning of life?")
print(f"Response: {response.text}")
# With parameters
params = (
TextGenerationParams(prompt="Explain quantum computing")
.with_max_tokens(1024)
.with_temperature(0.7)
)
response = await client.generate_text_large(params)
print(f"Tokens used: {response.usage.total_tokens()}")
asyncio.run(main())
JSON Object Generation
import asyncio
from elizaos_plugin_anthropic import AnthropicClient, AnthropicConfig, ObjectGenerationParams
async def main():
config = AnthropicConfig.from_env()
async with AnthropicClient(config) as client:
# Simple prompt
response = await client.generate_object_small(
"Create a JSON object with name, age, and email fields"
)
print(f"Generated: {response.object}")
# With parameters
params = ObjectGenerationParams(
prompt="Create a user profile with nested address",
temperature=0.2,
)
response = await client.generate_object_large(params)
print(f"User: {response.object}")
asyncio.run(main())
Configuration
Environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
ANTHROPIC_API_KEY |
Yes | - | Your Anthropic API key |
ANTHROPIC_BASE_URL |
No | https://api.anthropic.com |
API base URL |
ANTHROPIC_SMALL_MODEL |
No | claude-3-5-haiku-20241022 |
Small model ID |
ANTHROPIC_LARGE_MODEL |
No | claude-sonnet-4-20250514 |
Large model ID |
ANTHROPIC_TIMEOUT_SECONDS |
No | 60 |
Request timeout |
Models
Available models:
| Model | Size | Description |
|---|---|---|
claude-3-5-haiku-20241022 |
Small | Fast and efficient |
claude-sonnet-4-20250514 |
Large | Most capable |
claude-3-5-sonnet-20241022 |
Large | Balanced performance |
claude-3-opus-20240229 |
Large | Previous flagship |
Testing
Install development dependencies:
pip install -e ".[dev]"
Run unit tests:
pytest -v
Run integration tests (requires API key):
# Create .env file with your API key
echo "ANTHROPIC_API_KEY=your-key" > .env
# Run integration tests
pytest -m integration
Type Checking
mypy elizaos_plugin_anthropic
License
MIT
Metadata
Release files for elizaos-plugin-anthropic 2.0.0a5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| elizaos_plugin_anthropic-2.0.0a5.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| elizaos_plugin_anthropic-2.0.0a5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.2 kB
Release files / elizaos_plugin_anthropic-2.0.0a5.tar.gz
| Download URL | elizaos_plugin_anthropic-2.0.0a5.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c917d2cc1b71551400986de3f3b33bf73cf87c01a6a9ca8566f1579d64dca6c5
|
|
BLAKE2b-256 checksum How to use checksums |
d0817a823eb802052d08314c5540fe62acee250ef34b4b017a4305acde3205f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / elizaos_plugin_anthropic-2.0.0a5-py3-none-any.whl
| Download URL | elizaos_plugin_anthropic-2.0.0a5-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb83d04134e2be40598ef6c4cc3a47ceef003551fdabbbfc970c2b14cf1d7b44
|
|
BLAKE2b-256 checksum How to use checksums |
611978617a91d59207593b65676d308560c17f07ea5a9a5aab83e8cc2c6f9b81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|