Documentation
Get started in minutes. Track your AI usage with just a few lines of code.
Supported: OpenAI, Anthropic, Gemini|Coming soon: Mistral, Groq, DeepSeek
Quick Start
1. Install the SDK
bash
npm install @with-orbit/sdk2. Initialize and wrap your client
javascript
import { Orbit } from '@with-orbit/sdk';
import OpenAI from 'openai';
const orbit = new Orbit({
apiKey: process.env.ORBIT_API_KEY,
});
// Wrap your OpenAI client
const openai = orbit.wrapOpenAI(new OpenAI());Get your API key from Settings in your dashboard.
3. Add feature tracking
javascript
// Track usage by feature
const chatClient = orbit.wrapOpenAI(new OpenAI(), {
feature: 'chat-assistant',
environment: 'production',
});
// Make API calls as normal
const response = await chatClient.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
});Agentic Task Tracking
NewGroup multi-step LLM workflows together and attribute costs to specific customers. Perfect for AI agents that make multiple API calls per task.
task_id
Groups all LLM calls in a workflow together. Track total cost and token usage per task.
customer_id
Attribute AI costs to specific customers. Essential for usage-based billing.
javascript
// Group LLM calls by task and customer
const agent = orbit.wrapOpenAI(new OpenAI(), {
feature: 'ai-agent',
task_id: 'task_abc123', // Groups all calls for this task
customer_id: 'cust_xyz789', // Attributes cost to this customer
});
// All calls with this client are tracked together
await agent.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Step 1: Analyze data...' }],
});
await agent.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Step 2: Generate report...' }],
});What gets tracked
The SDK captures metadata about each AI request. Your prompts and responses are never sent to Orbit.
Feature name
Group requests by feature
Model
gpt-4o, claude-3, etc.
Tokens
Input and output counts
Latency
Request to response time
Cost
Estimated based on pricing
Status
Success or error
Task ID
Group multi-step workflows
Customer ID
Attribute costs per customer
Environment Variables
bash
# Add to your .env file
ORBIT_API_KEY=orb_live_xxxxxxxxxxxx
OPENAI_API_KEY=sk-xxxxxxxxxxxxNote: Never commit API keys to version control.
SDK Features
Non-blocking
Analytics sent asynchronously
Lightweight
Minimal dependencies
Type-safe
Full TypeScript support
Secure
Your API keys never leave your app