Metadata-Version: 2.4
Name: elizaos-plugin-anthropic
Version: 2.0.0a5
Summary: elizaOS Anthropic Plugin - Claude API client for text and object generation
Project-URL: Homepage, https://github.com/elizaos/eliza
Project-URL: Documentation, https://elizaos.ai/docs
Project-URL: Repository, https://github.com/elizaos/eliza
Author: elizaOS Contributors
License-Expression: MIT
License-File: LICENSE
Keywords: agents,ai,anthropic,claude,elizaos,llm
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.10.0
Provides-Extra: dev
Requires-Dist: mypy>=1.19.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest-cov>=6.0.0; extra == 'dev'
Requires-Dist: pytest-xprocess>=1.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: python-dotenv>=1.0.0; extra == 'dev'
Requires-Dist: ruff>=0.14.0; extra == 'dev'
Description-Content-Type: text/markdown

# 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

```bash
pip install elizaos-plugin-anthropic
```

## Usage

### Text Generation

```python
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

```python
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:

```bash
pip install -e ".[dev]"
```

Run unit tests:

```bash
pytest -v
```

Run integration tests (requires API key):

```bash
# Create .env file with your API key
echo "ANTHROPIC_API_KEY=your-key" > .env

# Run integration tests
pytest -m integration
```

## Type Checking

```bash
mypy elizaos_plugin_anthropic
```

## License

MIT
