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

# Anthropic Integration

> Integrate Lumina with Anthropic Claude models

Complete guide to integrating Anthropic Claude with Lumina.

***

## Installation

```bash theme={null}
npm install @uselumina/sdk @anthropic-ai/sdk
```

***

## Basic Usage

```typescript theme={null}
import { initLumina } from '@uselumina/sdk';
import Anthropic from '@anthropic-ai/sdk';

const anthropic = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
});

const lumina = initLumina({
  endpoint: 'http://localhost:9411/v1/traces',
  service_name: 'anthropic-app',
});

const response = await lumina.traceLLM(
  () =>
    anthropic.messages.create({
      model: 'claude-sonnet-4-5',
      max_tokens: 1024,
      messages: [{ role: 'user', content: 'Hello!' }],
    }),
  {
    name: 'chat-completion',
    system: 'anthropic',
    prompt: 'Hello!',
  }
);
```

***

## Supported Models

| Model             | Cost Calculation | Token Tracking |
| ----------------- | ---------------- | -------------- |
| Claude Sonnet 4.5 | ✓                | ✓              |
| Claude 3.5 Sonnet | ✓                | ✓              |
| Claude 3 Opus     | ✓                | ✓              |
| Claude 3 Sonnet   | ✓                | ✓              |
| Claude 3 Haiku    | ✓                | ✓              |

***

## Streaming

```typescript theme={null}
const stream = await lumina.traceLLM(
  () =>
    anthropic.messages.create({
      model: 'claude-sonnet-4-5',
      max_tokens: 1024,
      messages: [{ role: 'user', content: 'Hello!' }],
      stream: true,
    }),
  { name: 'chat-stream', system: 'anthropic' }
);

for await (const event of stream) {
  if (event.type === 'content_block_delta') {
    process.stdout.write(event.delta.text);
  }
}
```

***

## Tool Use

```typescript theme={null}
await lumina.traceLLM(
  () =>
    anthropic.messages.create({
      model: 'claude-sonnet-4-5',
      max_tokens: 1024,
      messages: [{ role: 'user', content: 'What's the weather?' }],
      tools: [
        {
          name: 'get_weather',
          description: 'Get weather for location',
          input_schema: {
            type: 'object',
            properties: {
              location: { type: 'string' },
            },
          },
        },
      ],
    }),
  { name: 'tool-use', system: 'anthropic' }
);
```
