Anthropic Integration
Updated on Aug 14, 2026
Use this integration when your app is implemented in Python, TypeScript, or .NET.
Setup
- Install SDK
bash
pip install progress-observability
- Instrument your app
python
Observability.instrument(
app_name=os.getenv("OBSERVABILITY_APP_NAME"),
api_key=os.getenv("OBSERVABILITY_API_KEY")
)
- Complete example
python
import os
from anthropic import Anthropic
from dotenv import load_dotenv
from progress.observability import Observability
load_dotenv()
# LLM INSTRUMENTATION
Observability.instrument(
app_name=os.getenv("OBSERVABILITY_APP_NAME"),
api_key=os.getenv("OBSERVABILITY_API_KEY"),
)
def main() -> None:
client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
model = os.getenv("ANTHROPIC_MODEL", "claude-haiku-4-5-20251001")
response = client.messages.create(
model=model,
max_tokens=256,
system="You are a helpful AI assistant.",
messages=[{"role": "user", "content": "What is the capital of France?"}],
)
try:
main()
finally:
Observability.shutdown()
To get a richer trace tree when building agents on top of this provider, use the
@agent,@tool,@workflow, or@taskdecorators. See the Python SDK for details.
- Install SDK
bash
npm install @progress/observability
- Instrument your app
TS
import '@progress/observability/register/hooks';
import { Observability } from '@progress/observability';
await Observability.instrument({
appName: process.env.OBSERVABILITY_APP_NAME,
apiKey: process.env.OBSERVABILITY_API_KEY
});
- Complete example
TS
import '@progress/observability/register/hooks';
import 'dotenv/config';
import Anthropic from '@anthropic-ai/sdk';
import { Observability } from '@progress/observability';
const anthropicModel =
process.env.ANTHROPIC_MODEL || 'claude-haiku-4-5-20251001';
async function main() {
await Observability.instrument({
appName: process.env.OBSERVABILITY_APP_NAME ?? 'weather-agent-anthropic-sdk',
apiKey: process.env.OBSERVABILITY_API_KEY,
});
try {
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const result = await client.messages.create({
model: anthropicModel,
max_tokens: 256,
temperature: 0.7,
system: 'You are a helpful AI assistant.',
messages: [{ role: 'user', content: 'What is the capital of France?' }],
});
const textResponse = result.content
.filter((block) => block.type === 'text')
.map((block) => block.text)
.join('\n');
} finally {
await Observability.shutdown();
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
To get a richer trace tree when building agents on top of this provider, use the
@agent,@tool,@workflow, or@taskdecorators. See the TypeScript SDK for details.
- Install SDK
bash
dotnet add package Progress.Observability.Instrumentation
- Instrument your app
cs
try
{
chatClient = chatClient.AddObservability((options) =>
{
options.AppName = Environment.GetEnvironmentVariable("OBSERVABILITY_APP_NAME")!;
options.ApiKey = Environment.GetEnvironmentVariable("OBSERVABILITY_API_KEY")!;
});
// Your code here.
}
finally
{
// Call the Shutdown() method before exiting your agent to flush any remaining data.
ObservabilityTracer.Shutdown();
}
- Complete example
cs
using Anthropic.SDK;
using Anthropic.SDK.Constants;
using Microsoft.Extensions.AI;
using System.ComponentModel;
using Progress.Observability.Extensions.AI;
using DotNetEnv;
namespace Examples.Anthropic;
/// <summary>
/// Example demonstrating Microsoft.Extensions.AI support for Anthropic.
/// </summary>
public class Program
{
[Description("Get the weather for a given location.")]
static string GetWeather([Description("The location to get the weather for.")] string location)
=> $"The weather in {location} is cloudy with a high of 15°C.";
public static async Task Main(string[] args)
{
try
{
Env.Load(".env");
// Create Anthropic client using the provider SDK
var anthropicClient = new AnthropicClient(
Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY")!);
// Convert to IChatClient using Anthropic's Messages API
IChatClient chatClient = anthropicClient.Messages
// Add observability instrumentation
.AddObservability((options) =>
{
options.AppName = "Anthropic Example";
options.ApiKey = Environment.GetEnvironmentVariable("OBSERVABILITY_API_KEY")!;
})
// Enable automatic function invocation
.AsBuilder()
.UseFunctionInvocation()
.Build();
// Configure model and tools
var options = new ChatOptions
{
ModelId = AnthropicModels.Claude45Haiku,
MaxOutputTokens = 512,
Tools = [AIFunctionFactory.Create(GetWeather)]
};
// Add tool observability
options.AddToolObservability();
var response = await chatClient.GetResponseAsync(
"What is the capital of France?",
options);
Console.WriteLine(response.Text ?? "No assistant text returned.");
}
finally
{
ObservabilityTracer.Shutdown();
}
}
}
To get a richer trace tree when building agents on top of this provider, use custom spans. See the .NET SDK for details.