Developer Guide · Start here
Quickstart
Bear Lumen tracks the AI calls you already make. There are two ways to send us usage: our SDK or the REST API. Pick the one that fits your stack, then follow that guide. Not ready to install anything? The SDK Playground runs the whole loop from your browser.
Before you start
- A Bear Lumen account (get started here)
- An API key from your dashboard settings with the
usage:writescope, pluscosts:readif you want to read costs back - An AI provider you already call (OpenAI, Anthropic, Google, and more)
Choose your path
SDK Quickstart
Node.js or Python. Install the SDK, then pass each AI response to bear.track(). It auto-detects the provider, model, and token usage; cost is calculated server-side. Best when you call AI from a Node or Python service. Wrap your client once for automatic tracking, and trace multi-call agent runs with spans.
REST API
Any language. Post usage events to /v1/usage-events over HTTP with cURL, Postman, or your own client. No SDK required. Best for Go, Ruby, PHP, or edge runtimes.
SDK Playground
No install at all. Run the SDK from your browser as step-by-step notebooks: wrap a simulated provider client, make calls with a test API key, and watch real costs land in a live panel. The fastest way to see the whole loop work.
Calling AI from an agent? Trace the whole run
The SDK path does more than per-call tracking. Wrap your provider client once and every call is tracked automatically, then group a multi-call agent run into a span to get the full call tree, cost per outcome, and budget limits. See Tracing agentic work.
Then what? Reading your costs
Once you're tracking, the same numbers are available two ways, with no extra setup. Ingestion is asynchronous, so allow a short delay after your first events before the numbers appear. Query the summary endpoints (bear.costs.summary() or GET /v1/cost-data/summary) to wire an AI agent or MCP server straight to your spend, or skip the code and read the same breakdowns in your dashboard.
Need help?
Our team is here to help you get the most out of Bear Lumen. Email support →