Introduction
Evaluation
- Overview
- Quickstart
- Future AGI Models
- Concept
- How To
- Eval Definition
Dataset
- Overview
- Concept
- Adding Dataset
- Create Dynamic Column
- Add Annotations
- Change Column Type
- Create Static Column
- Create Synthetic Data
- Experimentation
Tracing
MCP
Admin & Settings
Instrumentation ( Auto )
Anthropic
1. Installation
First install the traceAI and Anthropic packages.
Copy
Ask AI
pip install traceAI-anthropic anthropic
Copy
Ask AI
pip install traceAI-anthropic anthropic
Copy
Ask AI
npm install @traceai/anthropic @anthropic-ai/sdk
2. Set Environment Variables
Set up your environment variables to authenticate with both FutureAGI and Anthropic.
Copy
Ask AI
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
Copy
Ask AI
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
Copy
Ask AI
process.env.FI_API_KEY = FI_API_KEY;
process.env.FI_SECRET_KEY = FI_SECRET_KEY;
process.env.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 .
Copy
Ask AI
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="anthropic_project",
)
Copy
Ask AI
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="anthropic_project",
)
Copy
Ask AI
import { register, ProjectType } from "@traceai/fi-core";
const traceProvider = 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.
Copy
Ask AI
from traceai_anthropic import AnthropicInstrumentor
AnthropicInstrumentor().instrument(tracer_provider=trace_provider)
Copy
Ask AI
from traceai_anthropic import AnthropicInstrumentor
AnthropicInstrumentor().instrument(tracer_provider=trace_provider)
Copy
Ask AI
import { AnthropicInstrumentation } from "@traceai/anthropic";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
const anthropicInstrumentation = new AnthropicInstrumentation({});
registerInstrumentations({
instrumentations: [anthropicInstrumentation],
tracerProvider: tracerProvider,
});
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.
Copy
Ask AI
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)
Copy
Ask AI
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)
Copy
Ask AI
import { Anthropic } from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const message = await client.messages.create({
model: "claude-3-7-sonnet-20250219",
max_tokens: 50,
messages: [{ role: "user", content: "Hello Claude! Write a short haiku." }],
});
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.