Installation
Copy
npm install @uselumina/sdk @anthropic-ai/sdk
Basic Usage
Copy
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
Copy
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
Copy
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' }
);