1. Installation
First install the traceAI and Anthropic packages.
pip install traceAI-anthropic
pip install anthropic
2. Set Environment Variables
Set up your environment variables to authenticate with both FutureAGI and Anthropic.
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
3. Initialize Trace Provider
Set up the trace provider to create a new project in FutureAGI, establish telemetry data pipelines .
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="anthropic_project",
)
4. Instrument your Project
Instrument your Project with Anthropic Instrumentor. This step ensures that all interactions with the Anthropic are tracked and monitored.
from traceai_anthropic import AnthropicInstrumentor
AnthropicInstrumentor().instrument(tracer_provider=trace_provider)
5. Interact with Anthropic
Interact with the Anthropic as you normally would. Our Instrumentor will automatically trace and send the telemetry data to our platform.
import anthropic
import httpx
import base64
image_url = "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg"
image_media_type = "image/jpeg"
image_data = base64.standard_b64encode(httpx.get(image_url).content).decode("utf-8")
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-3-7-sonnet-20250219",
messages=[
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": image_media_type,
"data": image_data,
},
},
{
"type": "text",
"text": "Describe this image."
}
],
}
],
)
print(message)