Use this file to discover all available pages before exploring further.
Phoenix provides auto-instrumentation for the Anthropic Python SDK and Anthropic TypeScript SDK, allowing you to trace all calls to Claude models.Anthropic’s Claude models are state-of-the-art LLMs with extended context windows and strong performance on reasoning tasks. Phoenix makes it easy to observe Claude’s behavior in production.
from phoenix.otel import register# Configure the Phoenix tracertracer_provider = register( project_name="my-llm-app", # Default is 'default' auto_instrument=True # Auto-instrument based on installed packages)
import anthropicclient = anthropic.Anthropic()with client.messages.stream( model="claude-3-5-sonnet-20240620", max_tokens=1024, messages=[ {"role": "user", "content": "Write a short poem about AI observability"} ],) as stream: for text in stream.text_stream: print(text, end="", flush=True)# Phoenix captures the full streamed response
import anthropicimport jsonclient = anthropic.Anthropic()# Define toolstools = [ { "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" } }, "required": ["location"] } }]message = client.messages.create( model="claude-3-5-sonnet-20240620", max_tokens=1024, tools=tools, messages=[{"role": "user", "content": "What's the weather like in San Francisco?"}])# Phoenix captures tool definitions and callsif message.stop_reason == "tool_use": for content in message.content: if content.type == "tool_use": print(f"Tool: {content.name}") print(f"Input: {content.input}")
import anthropicclient = anthropic.Anthropic()message = client.messages.create( model="claude-3-5-sonnet-20240620", max_tokens=1024, system="You are a helpful AI assistant specialized in Python programming.", messages=[ {"role": "user", "content": "How do I read a CSV file?"}, {"role": "assistant", "content": "You can use the pandas library..."}, {"role": "user", "content": "What if I don't have pandas?"} ])print(message.content[0].text)