π οΈIntegration Options for AI Metering
Overview
Revenium SDKs wrap your AI providerβs client library to automatically capture token usage, costs, latencies, and metadata β no changes to your API logic required. Data flows to the AI Analytics and Alerts dashboards in real time.
Python SDK
Install: pip install revenium-python-sdk
The unified Python SDK supports all major AI providers through optional extras. Install only the providers you need:
OpenAI
pip install "revenium-python-sdk[openai]"
β
β
Azure OpenAI
pip install "revenium-python-sdk[openai]"
β
β
Anthropic
pip install "revenium-python-sdk[anthropic]"
β
Anthropic has no embedding models
Anthropic via AWS Bedrock
pip install "revenium-python-sdk[anthropic]"
β
Anthropic has no embedding models
Google Gemini (AI SDK)
pip install "revenium-python-sdk[google-genai]"
β
β
Google Vertex AI (Enterprise)
pip install "revenium-python-sdk[google-vertex]"
β
β
LiteLLM
pip install "revenium-python-sdk[litellm]"
β
β
LiteLLM Proxy
pip install "revenium-python-sdk[litellm-proxy]"
β
β
Ollama
pip install "revenium-python-sdk[ollama]"
β
β
Perplexity (OpenAI-compatible)
pip install "revenium-python-sdk[perplexity-openai]"
β
Perplexity does not currently support embeddings
Perplexity (Native)
pip install "revenium-python-sdk[perplexity-native]"
β
Perplexity does not currently support embeddings
Fal.ai (image, video, audio metering)
pip install "revenium-python-sdk[fal]"
β
β
LangChain
pip install "revenium-python-sdk[langchain]"
β
β
You can install multiple providers at once: pip install "revenium-python-sdk[openai,anthropic,langchain]"
Node.js SDKs
All Node.js SDKs are available on npm.
Go SDKs
OpenAI
β
β
β
β
β
Azure OpenAI
β
β
β
β
β
Anthropic
β
Anthropic has no embedding models
β
β
β
β
β
β
β
β
Perplexity
β
Perplexity does not currently support embeddings
β
β
β
Fal.ai
β
β
β
β
β
Runway
β
β
β
β
β
Go SDKs are available on GitHub.
LangChain
The wrap() function attaches a callback handler that reports usage data to Revenium's metering API. See the SDK README for additional examples.
For LangChain apps already using OpenTelemetry, see OpenTelemetry Integration as an alternative path.
Other Framework Integrations
AI Coding Assistants
Revenium ingests telemetry from AI coding assistants via OpenTelemetry, tracking adoption and usage across your engineering team.
Claude Code
β Supported
Gemini CLI
β Supported
Setup: configure the tool's OTLP exporter to point at Revenium β see OpenTelemetry Integration. Usage data appears in the AI Coding Dashboard.
Multimodal Cost Tracking
Revenium tracks costs across all AI modalities in a single view: Completions, Images, Video, and Audio.
Using a different SDK or framework? Revenium supports direct API calls and OpenTelemetry for any application. Contact [email protected] for integration assistance.
Using an AI agent? Revenium docs are available in Claude Code, Cursor, Windsurf, and other MCP-compatible agents via Context7. See For AI Agents.
Usage Metadata Reference
Each SDK accepts an optional usage_metadata object for billing, cost attribution, and alerting. The more fields you provide, the more granular your reporting.
Key fields: traceId, taskType, organizationId, subscriptionId, productId, agent, responseQualityScore, subscriber (with id, email, credential).
For field definitions, naming conventions, and examples, see each SDK's documentation on npm or PyPI. For OTEL-based attribution, see the revenium.* attributes in the OpenTelemetry Integration docs.
Direct API Integration
For complete customization, use the metering API directly:
A 201 response does NOT confirm your payload was processed correctly. The metering API returns 201 Created even when your payload contains unrecognized fields. Misspelled or incorrect field names are silently ignored, which can result in $0 cost calculations. Always verify the calculated cost in the AI Analytics dashboard after your first integration.
Common field-name mistakes:
imageCount(ignored) vsactualImageCount(correct)audioLength(ignored) vsaudioDurationSeconds(correct)stop_reason(ignored) vsstopReason(correct)
Required field: stopReason β For completion metering, the stopReason field is required. Valid values: END, END_SEQUENCE, TOKEN_LIMIT, COST_LIMIT, COMPLETION_LIMIT, ERROR, TIMEOUT, CANCELLED. Omitting this field or sending an invalid value (e.g., MAX_TOKENS, CONTENT_FILTER, STOP) will result in a 400 Bad Request.
Authentication errors return 403, not 401. If your API key is missing or invalid, the metering API returns 403 Forbidden. You will not receive a 401 Unauthorized response.
Last updated
Was this helpful?