phi-core 0.10.0

Simple, effective agent loop with tool execution and event streaming
Documentation
<!-- Last verified: 2026-04-05 by Claude Code -->
# Anthropic Provider

Handles the Anthropic Messages API with SSE streaming. Selected automatically when `ModelConfig.api == ApiProtocol::AnthropicMessages`.

## Usage

```rust
use phi_core::BasicAgent;
use phi_core::provider::ModelConfig;

let api_key = std::env::var("ANTHROPIC_API_KEY").unwrap();
let agent = BasicAgent::new(ModelConfig::anthropic(
    "claude-sonnet-4-20250514",
    "Claude Sonnet 4",
    &api_key,
));
```

## Features

### Streaming SSE

Uses `reqwest-eventsource` to parse Anthropic's SSE stream. Events handled:

- `message_start` — Input token usage, cache stats
- `content_block_start` — Text, thinking, or tool_use block
- `content_block_delta` — Text, thinking, input JSON, or signature deltas
- `content_block_stop` — Block complete
- `message_delta` — Stop reason, output usage
- `message_stop` — Stream complete

### Extended Thinking

Set `thinking_level` to enable thinking with a token budget:

| Level | Budget Tokens |
|-------|--------------|
| `Minimal` | 128 |
| `Low` | 512 |
| `Medium` | 2,048 |
| `High` | 8,192 |

Thinking content is streamed as `Content::Thinking` with a cryptographic `signature` for verification.

### Cache Control

Automatic prompt caching via `cache_control` markers:

- **System prompt**: Always cached with `{"type": "ephemeral"}`
- **Second-to-last message**: Gets `cache_control` on its last content block, creating a cache breakpoint

This means on repeated calls, only the latest message is processed at full price.

## Configuration

| Setting | Value |
|---------|-------|
| API URL | `https://api.anthropic.com/v1/messages` |
| API Version | `2023-06-01` |
| Auth Header | `x-api-key` |
| Default Max Tokens | 8,192 |

## Environment Variables

| Variable | Purpose |
|----------|---------|
| `ANTHROPIC_API_KEY` | API key |