Skip to main content
Complete guide to integrating Anthropic Claude with Lumina.

Installation

npm install @uselumina/sdk @anthropic-ai/sdk

Basic Usage

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

ModelCost CalculationToken Tracking
Claude Sonnet 4.5
Claude 3.5 Sonnet
Claude 3 Opus
Claude 3 Sonnet
Claude 3 Haiku

Streaming

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

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' }
);