> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeyhive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Anthropic

> Learn how to integrate Anthropic with HoneyHive

export const integrationType_1 = "Anthropic"

export const integrationType_0 = "Anthropic"

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

With HoneyHive, you can trace all your {integrationType_0} operations using a single line of code. Find a list of all supported integrations [here](/introduction/troubleshooting#latest-package-versions-tested).

## HoneyHive Setup

Follow the [HoneyHive Installation Guide](/integrations/integration-prereqs) to get your API key and initialize the tracer.

## Anthropic Setup

Go to the [Anthropic Cloud Console](https://console.anthropic.com/settings/keys) to get your Anthropic API key.

## Example

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

<CodeGroup>
  ```python Python theme={null}
  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()
  ```

  ```typescript TypeScript theme={null}

  import { Anthropic } from '@anthropic-ai/sdk';
  import { HoneyHiveTracer } from 'honeyhive';

  const tracer = await HoneyHiveTracer.init({
      apiKey: 'MY_HONEYHIVE_API_KEY',
      project: 'MY_HONEYHIVE_PROJECT_NAME',
      sessionName: 'anthropic'
  });

  const client = new Anthropic({
      apiKey: 'MY_ANTHROPIC_API_KEY',
  });

  interface Message {
      role: 'user' | 'assistant';
      content: string;
  }

  async function chat(messages: Message[]): Promise<string> {
      const response = await client.messages.create({
          model: 'claude-3-5-sonnet-20241022',
          max_tokens: 1024,
          messages: messages
      });
      return response.content[0].text;
  }

  async function simulateConversation(): Promise<void> {
      const messages: Message[] = [
          { role: 'user', content: 'Hello, Claude! How are you today?' }
      ];
      
      let assistantResponse = await chat(messages);
      console.log(`User: ${messages[0].content}`);
      console.log(`Assistant: ${assistantResponse}`);

      messages.push({ role: 'assistant', content: assistantResponse });
      messages.push({ role: 'user', content: 'What can you tell me about artificial intelligence?' });
      
      assistantResponse = await chat(messages);
      console.log(`User: ${messages[2].content}`);
      console.log(`Assistant: ${assistantResponse}`);

      messages.push({ role: 'assistant', content: assistantResponse });
      messages.push({ role: 'user', content: 'Can you give me an example of its applications?' });
      
      assistantResponse = await chat(messages);
      console.log(`User: ${messages[4].content}`);
      console.log(`Assistant: ${assistantResponse}`);
  }

  const tracedSimulateConversation = tracer.traceFunction()(simulateConversation);

  // Execute the conversation
  await tracedSimulateConversation();

  ```
</CodeGroup>

## View your Traces

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

<img src="https://mintcdn.com/honeyhiveai/oxFnPfpA79Ja1RXX/images/traces/anthropic-trace.png?fit=max&auto=format&n=oxFnPfpA79Ja1RXX&q=85&s=2a507f7c2fd92bd0a3f82585004c7112" alt="Anthropic Traces" width="1107" height="874" data-path="images/traces/anthropic-trace.png" />
