Anthropic OpenTelemetry Integration
Overview
This integration provides support for using OpenTelemetry with the Anthropic framework. It enables tracing and monitoring of applications built with Anthropic.
Installation
- Install traceAI Anthropic
pip install traceAI-anthropic
Set Environment Variables
Set up your environment variables to authenticate with FutureAGI
import os
os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY
os.environ["ANTHROPIC_API_KEY"] = ANTHROPIC_API_KEY
Quickstart
Register Tracer Provider
Set up the trace provider to establish the observability pipeline. The trace provider:
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="anthropic_app"
)
Configure Anthropic Instrumentation
Instrument the Anthropic client to enable telemetry collection. This step ensures that all interactions with the Anthropic SDK are tracked and monitored.
from traceai_anthropic import AnthropicInstrumentor
AnthropicInstrumentor().instrument(tracer_provider=trace_provider)
Anthropic SDK native tracing
Anthropic SDK 1.14.0 and later can trace Messages calls themselves. To send those spans to Future AGI without this instrumentor, pass the provider to the client:
client = anthropic.Anthropic(open_telemetry={"tracer_provider": trace_provider})
The SDK's spans include model, timing and token usage, and include prompts and responses only with "traces": {"content_mode": "content"}. TraceConfig, FI_HIDE_* settings and the using_session / using_attributes context (session, user, metadata, tags) don't apply to them.
When AnthropicInstrumentor is installed and the SDK's spans would reach the same tracer provider (because you pass it to the client, or because it is the global provider), the instrumentor records messages.create (sync and async) and sync messages.count_tokens calls itself and turns the SDK's span off for each of those calls, so each call is recorded once with the Future AGI context and privacy controls. Your client keeps its own open_telemetry option. To skip this per-call step, create the client with open_telemetry=False. messages.stream() and async messages.count_tokens are not wrapped by the instrumentor, so they keep the SDK's span.
Create Anthropic Components
Set up your Anthropic client with built-in observability.
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-3-5-sonnet-20240620",
max_tokens=1024,
tools=[
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The unit of temperature, either 'celsius' or 'fahrenheit'",
},
},
"required": ["location"],
},
},
{
"name": "get_time",
"description": "Get the current time in a given time zone",
"input_schema": {
"type": "object",
"properties": {
"timezone": {
"type": "string",
"description": "The IANA time zone name, e.g. America/Los_Angeles",
}
},
"required": ["timezone"],
},
},
],
messages=[
{
"role": "user",
"content": "What is the weather like right now in New York?"
" Also what time is it there? Use necessary tools simultaneously.",
}
],
)
print(response)
Metadata
Release files for traceAI-anthropic 0.1.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_anthropic-0.1.13.tar.gz | 21.5 kB | With provenance | Details for traceai_anthropic-0.1.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_anthropic-0.1.13-py3-none-any.whl | Python 3 | none | any | Details for traceai_anthropic-0.1.13-py3-none-any.whl |
Total release size: 45.3 kB
Release files / traceai_anthropic-0.1.13.tar.gz
| Download URL | traceai_anthropic-0.1.13.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5172c4b73ddf46db62ebad2b30c72283b51afeb5a3f1a7d7598de14a8e54bd9e
|
|
BLAKE2b-256 checksum How to use checksums |
e482fb7906916e3f08b42809a7274973281822be00b9316fdd9b88f15d5aa073
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / traceai_anthropic-0.1.13-py3-none-any.whl
| Download URL | traceai_anthropic-0.1.13-py3-none-any.whl |
|---|---|
| Size | 23.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65a7d6d67a42e868b5d3c7fd2b983d27296012e281a712651f14d4de860ec6ee
|
|
BLAKE2b-256 checksum How to use checksums |
bbf466e2c98035f087eaa681e6f100330d741edba8674630b07095a4d198e1e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for traceAI-anthropic 0.1.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for traceai_anthropic-0.1.13.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.