Quickstart: Observe
Track cost, revenue, and margin per customer in 5 minutes. No billing setup or Stripe required.
1. Get your API key
Sign up at dashboard.tansohq.com and choose Observe during onboarding. Your API key is on the Sources page -- copy it.
2. Send an event
Add this after any AI API call. Include the model and provider -- Tanso looks up current pricing automatically so you don't have to track rate cards yourself. If you know your exact cost, pass costAmount to override.
// Add after any AI API call
await fetch('https://api.tansohq.com/api/v1/client/events', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
eventIdempotencyKey: crypto.randomUUID(),
eventName: 'chat_completion',
customerReferenceId: 'cus_123',
featureKey: 'ai_summarization',
costInput: {
model: 'gpt-4o',
modelProvider: 'openai',
},
usageUnits: response.usage.total_tokens,
costAmount: 0.05,
})
})costInput.model+costInput.modelProvider-- Tanso uses these to calculate cost from current provider pricingcostAmount-- pass this to override with your actual cost (e.g., if you have a negotiated rate)revenueAmount-- what you charged your customer
Tanso calculates margin automatically. customerReferenceId can be any string you use to identify customers. Duplicate eventIdempotencyKey values return HTTP 409 -- safe to retry.
3. View your margins
Head to dashboard.tansohq.com and open Analytics. You'll see per-customer cost, revenue, and margin as soon as events start flowing. The Events page shows each individual event for debugging.
Optionally, create customers
To see names and emails in analytics instead of raw IDs, register customers first:
await fetch('https://api.tansohq.com/api/v1/client/customers', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
customerReferenceId: 'cus_123',
email: '[email protected]',
firstName: 'Jane',
lastName: 'Smith',
})
})Not required. You can send events with just a customerReferenceId and create customers later.
In practice
The pattern is always send events, check the dashboard:
app.post('/api/chat', async (req, res) => {
const result = await openai.chat.completions.create(req.body)
await fetch('https://api.tansohq.com/api/v1/client/events', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
eventIdempotencyKey: crypto.randomUUID(),
eventName: 'chat_completion',
customerReferenceId: req.userId,
featureKey: 'ai_chat',
costInput: {
model: 'gpt-4o',
modelProvider: 'openai',
},
usageUnits: result.usage.total_tokens,
costAmount: result.usage.total_tokens * 0.00003, // override with your negotiated rate
revenueAmount: 0.05,
})
})
res.json(result)
})Works for AI inference, API calls, file processing, or anything else you want to meter.
Video Tutorial
Have a question or feedback?
Join our discord or send an email to [email protected].
Ready for more?
When you're ready to enforce usage limits, manage subscriptions, and bill customers through Stripe, upgrade to Tanso Platform from Settings in the dashboard. Your event pipeline carries over -- zero code changes required.
Platform adds:
- Plans and pricing rules
- Entitlement enforcement (check before serving)
- Usage caps and credits
- Stripe integration and invoicing
Updated 23 days ago