Quick Start Guide
10 minGet up and running with Bear Lumen in 10 minutes. This guide will walk you through tracking your first AI API call and querying your costs.
SDKs Available — Start Tracking AI Costs in Minutes
Install the Node.js SDK: npm install @bearlumen/node-sdk
Install the Python SDK: pip install bearlumen
You can also use our REST API directly from any language.
Prerequisites
- A Bear Lumen account (sign up here)
- An API key from your (dashboard settings)
- Node.js 18+ or Python 3.9+ installed (or use REST API from any language)
- An AI provider API key (e.g., OpenAI, Anthropic) for making calls to track
Installation & Setup
Install the SDK
Install the Bear Lumen Node.js SDK:
npm install @bearlumen/node-sdkInitialize the Client
Set up your API client with your API key:
import { BearLumen } from '@bearlumen/node-sdk';
const bear = new BearLumen({
apiKey: process.env.BEAR_LUMEN_API_KEY,
});Track an AI Call
Make an AI API call and pass the response to Bear Lumen. It auto-detects the provider and extracts token counts and cost:
import OpenAI from 'openai';
const openai = new OpenAI();
const response = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
});
// Bear Lumen auto-detects the provider and extracts tokens + cost
const result = await bear.track(response);
console.log(`Cost: $${result.cost}`);Add Attribution
Tag calls with a user, feature, or agent to see where your AI spend is going:
// Add attribution to know who spent what and where
const result = await bear.track(response, {
userId: 'user_123',
feature: 'chat',
agentId: 'support-bot',
});
console.log(`User ${result.userId} spent $${result.cost} on ${result.model}`);Query Your Costs
OptionalPull cost breakdowns by model, provider, or user:
// See costs broken down by model
const byModel = await bear.costs.byModel({
startDate: '2025-01-01',
endDate: '2025-01-31',
});
console.log(byModel);
// See costs for a specific user
const userCosts = await bear.costs.forUser('user_123').summary();
console.log(userCosts);You're all set!
You're now tracking AI costs with Bear Lumen. Every call you track builds a real-time picture of your AI spending by model, user, and feature.