> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeyhive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Anthropic

> Add HoneyHive observability to your Anthropic Claude applications

[Anthropic](https://docs.anthropic.com/) provides Claude models for chat, tool use, and vision. HoneyHive integrates with Anthropic via the OpenInference instrumentor, automatically capturing all API calls, tool use, and token usage.

## Quick Start

<Tip>
  **Add HoneyHive tracing in just 4 lines of code.** Add this to your existing Anthropic app and all message calls, tool use, and streaming are automatically traced.
</Tip>

<Tip>
  To see where to initialize the tracer for your environment, including AWS Lambda and long-running servers, see [Tracer Initialization](/v2/tracing/tracer-initialization).
</Tip>

```bash theme={null}
pip install "honeyhive[openinference-anthropic]"

# Or install separately
pip install honeyhive openinference-instrumentation-anthropic anthropic
```

```python theme={null}
import os
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.anthropic import AnthropicInstrumentor

tracer = HoneyHiveTracer.init(
    api_key=os.getenv("HH_API_KEY"),
    project=os.getenv("HH_PROJECT"),
)
AnthropicInstrumentor().instrument(tracer_provider=tracer.provider)

# Your existing Anthropic code works unchanged
```

### Tested Versions

HoneyHive's Anthropic integration is tested against the following versions on PyPI, as of April 2026. Newer patch releases are generally safe; if you hit an issue, pin to these versions to reproduce a known-good configuration.

| Package                                   | Version                                                   |
| ----------------------------------------- | --------------------------------------------------------- |
| `anthropic`                               | `0.93.0` (minimum: `>= 0.17.0`, recommended: `>= 0.21.0`) |
| `openinference-instrumentation-anthropic` | `1.0.0`                                                   |

Requires Python 3.11+.

## What Gets Traced

The instrumentor automatically captures:

* **Message completions** - `client.messages.create()` with inputs, outputs, and token usage
* **Tool use** - Each tool call with arguments and results
* **Streaming responses** - Streamed messages with aggregated tokens

No manual instrumentation required.

***

## Example: Message Creation

```python theme={null}
import anthropic
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.anthropic import AnthropicInstrumentor

tracer = HoneyHiveTracer.init(project="your-project")
AnthropicInstrumentor().instrument(tracer_provider=tracer.provider)

client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-haiku-4-5-20251001",
    max_tokens=100,
    messages=[
        {"role": "user", "content": "What is the capital of France?"},
    ],
)
print(response.content[0].text)

# A follow-up call - also traced
response2 = client.messages.create(
    model="claude-haiku-4-5-20251001",
    max_tokens=100,
    messages=[
        {"role": "user", "content": "Tell me a fun fact about Paris."},
    ],
)
print(response2.content[0].text)
```

***

## Environment Configuration

```bash theme={null}
# HoneyHive configuration
export HH_API_KEY="your-honeyhive-api-key"
export HH_PROJECT="your-project"

# Anthropic configuration
export ANTHROPIC_API_KEY="your-anthropic-api-key"
```

***

## Troubleshooting

### Traces not appearing

1. **Check environment variables** - Ensure `HH_API_KEY` and `HH_PROJECT` are set
2. **Pass the tracer provider** - The instrumentor must receive `tracer_provider=tracer.provider`:

```python theme={null}
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.anthropic import AnthropicInstrumentor

tracer = HoneyHiveTracer.init(project="your-project")

# ✅ Correct - pass tracer_provider
AnthropicInstrumentor().instrument(tracer_provider=tracer.provider)

# ❌ Wrong - missing tracer_provider
AnthropicInstrumentor().instrument()
```

3. **Initialize before making calls** - Call `instrument()` before creating the Anthropic client

***

## Related

<CardGroup cols={2}>
  <Card title="Enrich Your Traces" icon="sparkles" href="/v2/tutorials/enriching-traces">
    Add user IDs and custom metadata to traces
  </Card>

  <Card title="Custom Spans" icon="code" href="/v2/tracing/custom-spans">
    Create spans for business logic around API calls
  </Card>

  <Card title="Distributed Tracing" icon="share-nodes" href="/v2/tutorials/distributed-tracing">
    Trace calls across service boundaries
  </Card>
</CardGroup>

***

## Using Traceloop (OpenLLMetry) Instead

If your project already uses [Traceloop / OpenLLMetry](https://github.com/traceloop/openllmetry), you can use its Anthropic instrumentor instead of OpenInference. The setup is identical - only the install and import paths differ.

```bash theme={null}
pip install "honeyhive[traceloop-anthropic]"
```

```python theme={null}
from honeyhive import HoneyHiveTracer
from opentelemetry.instrumentation.anthropic import AnthropicInstrumentor

tracer = HoneyHiveTracer.init(project="your-project")
AnthropicInstrumentor().instrument(tracer_provider=tracer.provider)
```

Tested version: `opentelemetry-instrumentation-anthropic` `0.58.0` (April 2026).

***

## Resources

* [Anthropic API Documentation](https://docs.anthropic.com/)
* [OpenInference Anthropic Instrumentor](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-anthropic)
* [Traceloop (OpenLLMetry) Anthropic Instrumentor](https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-anthropic)
