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

# Anthropic

## 1. Installation

First install the traceAI and Anthropic packages.

<CodeGroup>
  ```bash Python theme={null}
  pip install traceAI-anthropic anthropic
  ```

  ```bash JS/TS theme={null}
  npm install @traceai/anthropic @anthropic-ai/sdk
  ```
</CodeGroup>

***

## 2. Set Environment Variables

Set up your environment variables to authenticate with both FutureAGI and Anthropic.

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

  ```typescript JS/TS theme={null}
  process.env.FI_API_KEY = FI_API_KEY;
  process.env.FI_SECRET_KEY = FI_SECRET_KEY;
  process.env.ANTHROPIC_API_KEY = ANTHROPIC_API_KEY;
  ```
</CodeGroup>

***

## 3. Initialize Trace Provider

Set up the trace provider to create a new project in FutureAGI, establish telemetry data pipelines .

<CodeGroup>
  ```python Python theme={null}
  from fi_instrumentation import register
  from fi_instrumentation.fi_types import ProjectType

  trace_provider = register(
      project_type=ProjectType.OBSERVE,
      project_name="anthropic_project",
  )
  ```

  ```typescript JS/TS theme={null}
  import { register, ProjectType } from "@traceai/fi-core";

  const traceProvider = register({
      project_type: ProjectType.OBSERVE,
      project_name: "anthropic_project",
  });
  ```
</CodeGroup>

***

## 4. Instrument your Project

Instrument your Project with Anthropic Instrumentor. This step ensures that all interactions with the Anthropic are tracked and monitored.

<CodeGroup>
  ```python Python theme={null}
  from traceai_anthropic import AnthropicInstrumentor

  AnthropicInstrumentor().instrument(tracer_provider=trace_provider)
  ```

  ```typescript JS/TS theme={null}
  import { AnthropicInstrumentation } from "@traceai/anthropic";
  import { registerInstrumentations } from "@opentelemetry/instrumentation";

   const anthropicInstrumentation = new AnthropicInstrumentation({});

    registerInstrumentations({
      instrumentations: [anthropicInstrumentation],
      tracerProvider: tracerProvider,
    });
  ```
</CodeGroup>

***

## 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.

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

  ```typescript JS/TS theme={null}
  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." }],
      });
  ```
</CodeGroup>
