Anthropic is a company that builds AI models for natural language processing.

With HoneyHive, you can trace all your operations using a single line of code. Find a list of all supported integrations here.

HoneyHive Setup

Follow the HoneyHive Installation Guide to get your API key and initialize the tracer.

Anthropic Setup

Go to the Anthropic Cloud Console to get your Anthropic API key.

Example

Here is an example of how to trace your code in HoneyHive.

from anthropic import Anthropic
from honeyhive import HoneyHiveTracer

tracer = HoneyHiveTracer.init(
    api_key="MY_HONEYHIVE_API_KEY",
    project="MY_HONEYHIVE_PROJECT_NAME",
    session_name="anthropic"
)

client = Anthropic(
    api_key="MY_ANTHROPIC_API_KEY",
)

def chat(messages):
    message = client.messages.create(
        model="claude-3-5-sonnet-20241022",
        max_tokens=1024,
        messages=messages
    )
    return message.content[0].text



def simulate_conversation():
    messages = [
        {"role": "user", "content": "Hello, Claude! How are you today?"}
    ]
    
    assistant_response = chat(messages)
    print(f"User: {messages[0]['content']}")
    print(f"Assistant: {assistant_response}")

    messages.append({"role": "assistant", "content": assistant_response})
    messages.append({"role": "user", "content": "What can you tell me about artificial intelligence?"})
    
    assistant_response = chat(messages)
    print(f"User: {messages[2]['content']}")
    print(f"Assistant: {assistant_response}")

    messages.append({"role": "assistant", "content": assistant_response})
    messages.append({"role": "user", "content": "Can you give me an example of its applications?"})
    
    assistant_response = chat(messages)
    print(f"User: {messages[4]['content']}")
    print(f"Assistant: {assistant_response}")

simulate_conversation()

View your Traces

Once you run your code, you can view your execution trace in the HoneyHive UI by clicking the Data Store tab on the left sidebar.