SDK Setup
Use SDK Setup when you are instrumenting an application directly with Revenium SDKs, middleware, API keys, and integration identifiers. Start here if you are adding metering to code you own.
What You Need
A Revenium API key with the right scope for your integration.
Your tenant, team, and environment identifiers.
The API base URL for your workspace.
A choice of integration path: SDK, middleware, OTLP, MCP, Revvy CLI, or direct API.
Recommended Next Steps
Review API Key Permissions before creating production keys.
Choose an implementation path from Integration Options.
Use Provider Integrations for billing-provider account connections.
Use OTLP Integration if your stack already emits OpenTelemetry.
Python SDK
Install only the providers you need:
OpenAI or Azure OpenAI
pip install "revenium-python-sdk[openai]"
Anthropic or Anthropic via Bedrock
pip install "revenium-python-sdk[anthropic]"
Google Gemini
pip install "revenium-python-sdk[google-genai]"
Google Vertex AI
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
pip install "revenium-python-sdk[perplexity-openai]"
Fal.ai
pip install "revenium-python-sdk[fal]"
LangChain
pip install "revenium-python-sdk[langchain]"
You can install multiple extras together, for example:
AWS Bedrock permissions
The SDK calls Bedrock with your own AWS credentials, so those credentials need these IAM permissions. The two lookup permissions apply from SDK version 0.10.0.
bedrock:InvokeModel
Always.
bedrock:InvokeModelWithResponseStream
Always.
bedrock:GetInferenceProfile
When you call Claude by an application inference profile ARN, through raw boto3 with REVENIUM_BEDROCK_TRANSPORT=1 or through AnthropicBedrock with guardrail enforcement on.
bedrock:GetProvisionedModelThroughput
When you call Claude through a Provisioned Throughput ARN with REVENIUM_BEDROCK_TRANSPORT=1.
With REVENIUM_BEDROCK_TRANSPORT=1, raw boto3.client("bedrock-runtime") calls to Claude (invoke_model, invoke_model_with_response_stream, converse, converse_stream) are metered and capped. An application inference profile ARN (arn:aws:bedrock:<region>:<account>:application-inference-profile/<id>) and a Provisioned Throughput ARN (arn:aws:bedrock:<region>:<account>:provisioned-model/<id>) do not name the model, so the SDK looks each ARN up to learn which Claude model it runs. The lookup runs once per process, in the background, starting at the ARN's first call. It never delays your call, so calls made before it answers, usually only the first, are neither metered nor capped. After that, the SDK records and caps the call under that Claude model (for example anthropic.claude-haiku-4-5-20251001-v1:0).
A Provisioned Throughput call is recorded at the on-demand equivalent cost of its tokens, not the hourly price AWS bills. A cost cap fills at that rate, so a breached cost cap can stop calls on capacity you have already paid for.
With guardrail enforcement on, a sync AnthropicBedrock call by an application inference profile ARN is also capped under the Claude model the profile routes to. It uses the same lookup and the same bedrock:GetInferenceProfile permission.
If Bedrock returns AccessDenied, check that your credentials have bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream. Add bedrock:GetInferenceProfile if you use application inference profile ARNs, and bedrock:GetProvisionedModelThroughput if you use Provisioned Throughput ARNs.
Package: revenium-python-sdk on PyPI · Source & examples: github.com/revenium/revenium-python-sdk (examples)
Node.js Middleware
Use the unified middleware package and provider sub-paths:
OpenAI / Azure OpenAI
@revenium/middleware/openai
Anthropic
@revenium/middleware/anthropic
Google Vertex AI
@revenium/middleware/google/vertex
Google AI SDK
@revenium/middleware/google/genai
Perplexity
@revenium/middleware/perplexity
LiteLLM
@revenium/middleware/litellm
Install from npm:
Version 2.0.0 and later
Version 2.0.0 of @revenium/middleware adds:
Filtered guardrails. An enforced guardrail that filters on a provider, model, agent, product or another dimension stops only the calls it covers, and calls outside its filters go through. The middleware checks guardrails before OpenAI and Azure OpenAI chat completions. If your code builds an
EnforcementRuleobject, add itsfilterslist, typed by the exportedEnforcementFilter.Tool calls in a job.
meterToolandreportToolCallattach the job a tool call runs in, so the job's cost includes its tool calls. Both accept an optionalcostUsd, which Revenium charges in place of the price configured for that tool.Environment files. The middleware reads
.env.localand.envfrom the folder your application starts in. A value in.env.localwins over one in.env, and a variable already set in the environment wins over both. A.envin a parent folder is not read, so start the application in the folder that holds the file, or set the variables in the environment.
Package: @revenium/middleware on npm · Source & examples: github.com/revenium/revenium-node-sdk (examples)
Go SDK
Install:
Source & examples: github.com/revenium/revenium-go-sdk (examples) · Docs: pkg.go.dev
Install the provider module you need — openai here. Each provider ships as its own module.
Minimal OpenAI setup:
Frameworks and Agent Tooling
LangChain
Use the Python langchain extra, or use OTLP Integration if your app already emits OpenTelemetry.
n8n
Use the Revenium n8n middleware packages for OpenAI (n8n-nodes-revenium) or Anthropic (n8n-nodes-revenium-anthropic) agents.
OpenInference / OpenLLMetry
Use OTLP Integration.
Claude Code, Gemini CLI, Cursor, and other AI coding tools
Use Context7 and AI Docs Access, MCP Server, or Revvy CLI depending on the workflow.
JetBrains IDEs (IntelliJ, PyCharm, GoLand, etc.)
Use Revvy CLI for guided instrumentation — scans your codebase, finds AI call sites, and walks through SDK setup.
Usage Metadata
SDKs accept optional usage metadata for billing, attribution, and alerting. The fields accepted on POST /meter/v2/ai/completions are:
organizationName
Top-level customer account. Required — the legacy organizationId alias is silently dropped.
productName
Commercial tier or SKU. Required — the legacy productId alias is silently dropped.
subscriber
Object: { id, email, credential: { name, value } } — the end customer plus their specific API key.
agent
Agent name making the call; powers per-agent cost views and the Tool Registry.
traceId
Links sequential AI calls into a single execution path for Trace Analytics.
taskType
Categorises the work the agent was doing (qualification, support, code review, etc.).
subscriptionId
The Revenium subscription this call rates against.
responseQualityScore
0.0–1.0 evaluation score from RAGAS, LLM-as-judge, human review, or other quality signals.
ticketId
Optional engineering ticket or work-item identifier. Spend that carries it shows on Tickets; see Tie Agent Work to a Ticket.
At minimum, pass organizationName + productName. Add subscriber.id to attribute usage and cost to individual end users, and agent and traceId to unlock agent-level cost views and Trace Analytics. The remaining fields are optional.
For OpenTelemetry attribution, see the revenium.* attributes in OTLP Integration.
Related
Go SDK — pkg.go.dev · GitHub
Last updated
Was this helpful?