Three steps to complete AI cost visibility
npm install @tokentra/sdk
# or
pip install tokentraimport { TokenTra } from '@tokentra/sdk';
const tokentra = new TokenTra({
apiKey: 'tt_live_xxx'
});import OpenAI from 'openai';
const openai = tokentra.wrap(new OpenAI());
// Use as normal - costs are tracked automatically
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello!' }]
}, {
tokentra: {
feature: 'chat',
team: 'product',
userId: 'user_123'
}
});Your AI costs are now being tracked. Head to your TokenTra dashboard to see real-time spending data, set up alerts, and discover optimization opportunities.
All telemetry is sent asynchronously after the AI response is returned. Your API calls complete at exactly the same speed.
Batch telemetry collection ensures your application performance is never impacted by TokenTra.
We never see your prompts or responses. Only usage metrics and costs are collected.
Tag every AI request with custom attributes for granular cost tracking
// Add attribution to any request
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [...]
}, {
tokentra: {
// Required: Feature being used
feature: 'customer-support-chat',
// Optional: Team responsible
team: 'support-engineering',
// Optional: Project or product
project: 'helpdesk-v2',
// Optional: End user (for per-user economics)
userId: 'user_abc123',
// Optional: Custom tags for your use case
metadata: {
environment: 'production',
region: 'us-west',
experimentId: 'exp_456'
}
}
});See which teams are spending the most and enable internal chargebacks.
Understand the unit economics of every AI-powered feature in your product.
Calculate cost per user and identify heavy users driving your AI spend.
Add any custom tags for A/B tests, environments, or business-specific tracking.
Works with all major AI providers out of the box
GPT-5, GPT-5.1, GPT-5 Pro, o3, o3-mini, DALL-E 4, Whisper v3, Embeddings
Claude Opus 4.5, Claude Sonnet 4, Claude Haiku 4
Gemini 3 Pro, Gemini 3 Flash, Gemini 3 Ultra, Imagen 3
All OpenAI models via Azure deployments (GPT-5, o3)
Claude Opus 4.5, Titan v2, Llama 3, Mistral Large 2, Stable Diffusion 3
Full feature parity with the Node.js SDK
from tokentra import TokenTra
from openai import OpenAI
# Initialize TokenTra
tokentra = TokenTra(api_key='tt_live_xxx')
# Wrap your OpenAI client
openai = tokentra.wrap(OpenAI())
# Use as normal
response = openai.chat.completions.create(
model='gpt-4',
messages=[{'role': 'user', 'content': 'Hello!'}],
tokentra={
'feature': 'chat',
'team': 'product',
'user_id': 'user_123'
}
)
# Async support
import asyncio
from openai import AsyncOpenAI
async_openai = tokentra.wrap(AsyncOpenAI())
async def main():
response = await async_openai.chat.completions.create(
model='gpt-4',
messages=[{'role': 'user', 'content': 'Hello!'}]
)
asyncio.run(main())