Instrument Your Code
The fastest, lowest-maintenance way to send cost data to Revenium is the SDK plus your existing provider client (OpenAI, Anthropic, LiteLLM, etc.). The SDK handles the metering payload — including required fields and attribution — so you don't need to construct it yourself.
Send Data via the SDK
The Revenium Python SDK wraps your existing provider clients with a single line of code:
from openai import OpenAI
from revenium_middleware.openai import meter
client = meter(OpenAI()) # all completions are now metered to ReveniumFor other languages and providers (LiteLLM, OpenRouter, Anthropic, Google), see SDK Setup. The SDKs document the full set of supported fields, attribution metadata, and language-specific patterns in their READMEs and example libraries — treat them as the canonical reference for what to send.
Already on OpenTelemetry?
If your stack already emits OpenTelemetry, you don't need to add Revenium-specific instrumentation. Revenium accepts OTLP traces, metrics, and logs directly — point your OTel collector at the Revenium OTLP endpoint and your existing spans flow in, with span identifiers carrying over without remapping. For setup details, endpoints, and authentication, see OTLP Integration.
Enrich Calls with Business Attribution
Out of the box, the SDK sends model, token counts, and cost. To unlock the full dashboard — cost by customer, cost by product, agent ROI, trace analytics — pass attribution alongside each call:
organizationName— the customer account (parent company). The backend now requiresorganizationName; the legacyorganizationIdalias is silently dropped.productName— the commercial tier or SKU the customer is on. The backend now requiresproductName; the legacyproductIdalias is silently dropped.subscriber— sub-object identifying the end customer:{ id, email, credential: { name, value } }.agent— the specific agent making the call. Powers per-agent cost views and the Tool Registry.traceId— links sequential AI calls into a single workflow for Trace Analytics.taskType— categorises what the agent was doing (qualification, support, code review, etc.).
The more attribution you send, the more dimensions become available in dashboards, alerts, and cost controls. For the complete field list including subscription, quality scoring, and cost-control fields, see SDK Setup → Usage Metadata.
What You Can Meter
Revenium accepts more than just LLM completions. Send any combination of these event types — each has its own pricing curves and its own dashboard slice, so spend never collapses into a single number:
AI completions
LLM API calls — OpenAI, Anthropic, Bedrock, Google, and the long tail of providers
Tool events
Agent tool and function-call invocations — often as expensive or more than the LLM call itself
Agent outcomes
Terminal business result of an agent run — CONVERTED, DEFLECTED, ESCALATED, CUSTOM, with optional dollar value
Image generation
Image workloads (DALL·E, Stable Diffusion, fal.ai, provider-native vision)
Custom events
Arbitrary consumption units — OCR pages, retrieval rows scanned, document enrichments
Multimodal workloads benefit most from the dedicated endpoints — they apply the correct pricing curves automatically. Use custom events only when the unit you bill on doesn't fit a structured type.
Beyond Standard Tokens: Quality & Custom Metrics
Most teams start with tokens and latency. As AI workloads mature, two more dimensions become valuable:
Response quality measurement. Cost and latency tell you what you spent — they don't tell you whether the output was any good. The SDK can carry a quality score per call, sourced from whatever evaluation logic you trust: RAGAS-style retrieval evaluation, LLM-as-a-judge pipelines, downstream user feedback, or a human review queue. Once recorded, dashboards correlate quality against cost, model choice, agent, and customer — so you can see whether the cheaper model is actually losing you revenue, or whether one agent's outputs are systematically weaker than another's.
Custom consumption metrics. Some workloads are billed or evaluated in units that aren't tokens, audio seconds, or image counts — pages parsed by an OCR pipeline, rows scanned by a retrieval index, documents enriched by an extraction agent. Revenium accepts arbitrary numeric metrics alongside the standard event, so these workloads show up in cost-by-product and per-customer dashboards alongside LLM spend. Particularly useful when you're charging customers for an outcome rather than for tokens.
Direct API Integration
If you can't use the SDK (unsupported language, custom proxy, etc.), see the API Reference for the raw payload schema across all the event types listed above.
Related
SDK Setup — provider wrappers, language coverage, the canonical field reference
Provider Integrations — OpenAI, Anthropic, LiteLLM, OpenRouter, fal.ai
OTLP Integration — for stacks already on OpenTelemetry
AI Outcomes — close the ROI loop
Monitor Agent Tool Usage — meter tool calls alongside LLM calls
API Reference — raw HTTP API for direct integrations
Last updated
Was this helpful?