🛠️Integration Options for AI Metering

The latest list of integrations will always be available from inside the Revenium application when logged in.

Overview

Revenium provides middleware libraries and integration options to simplify metering across a wide range of AI frameworks, languages, and model providers. These integrations allow developers to automatically track token usage, costs, latencies, and metadata without rewriting core application logic.

Each middleware integration captures relevant details from the AI provider’s response and reports them to Revenium’s usage API. This enables immediate access to full observability and billing insights via the AI Analytics and Alerts dashboards.

Below is a summary of currently supported middleware integrations across languages, SDKs, and providers.


✅ Supported Middleware Integrations

Language
AI or Proxy Provider
Chat Completions
Embeddings

python

OpenAI

python

Azure OpenAI

python

liteLLM

python

ollama

🚧 In-Progress

python

Anthropic

Anthropic has no embedding models

python

Anthropic via aws bedrock

Anthropic has no embedding models

python

Google Vertex SDK (Enterprise)

python

Google ai SDK

python + Langchain extension

openAI

nodeJS

OpenAI

nodeJS

Azure OpenAI

nodeJS

liteLLM Proxy

n8n – Chat Agent

OpenAI

python – griptape driver

OpenAI


ℹ️ If you use a different SDK or framework not listed here, Revenium also supports direct API calls to our metering endpoint. You can forward usage data from any custom application or proxy with minimal integration effort.

📩 Contact [email protected] to request a custom SDK, integration assistance, or to contribute a plugin to the open middleware ecosystem.

Usage Metadata Reference

The usage_metadata object is used to pass additional fields to Revenium for billing, cost attribution, analytics, and alerting. These fields are optional, but the more you provide, the more granular and useful your reporting will be.

⚠️ Naming conventions: Field names are shown here in camelCase, which is recommended for JavaScript, TypeScript, and JSON-based integrations. For Python or other ecosystems, use idiomatic casing (e.g. snake_case in Python).


Top-Level Fields

Field
Description
Use Case

traceId

Unique ID for a session or conversation

Group multi-turn or batch requests for unified cost tracking

taskType

High-level classification of the AI task (e.g., summary, chat)

Attribute cost to types of work (summarization, retrieval, etc.)

organizationId

Customer or department ID from your systems

Track usage by external customer or internal business unit

subscriptionId

Identifier for billing plan or contract

Used for usage-based billing and quota enforcement

productId

Your internal product name or feature label

Group usage and cost by monetized product

agent

LLM identifier or orchestration wrapper name (e.g., gpt-4-summary)

Analyze agent-level performance or cost

responseQualityScore

Numeric score (0.0–1.0) indicating quality of the AI response

Measure perceived or model-generated quality

subscriber

See below — structured object defining the user or process that made call

Enables user-level attribution and grouping


Subscriber Object

The subscriber field can be a nested object to help organize and identify individual users or systems making the request.

Example

"subscriber": {
  "id": "[email protected]",
  "email": "[email protected]",
  "credential": {
    "name": "EHR Key – Nurse Station A",
    "value": "pk-ehra57"
  }
}

Fields

Field
Description

id

Unique internal identifier for the subscriber

email

Email address of the user (optional)

credential.name

Friendly label for the API key or access token

credential.value

Actual token used to authenticate the request

📘 Tip: For anonymous usage, you can set only the credential value. When the user is later identified, you can backfill the id or email to unify history.


🧠 Best Practices

  • Always send organizationId and subscriber.id to unlock the full value of per-customer and per-user cost tracking.

  • Use taskType, productId, and agent to group usage by product and capability for internal ROI reporting.

  • Set traceId to group multi-part requests (e.g., retrieval + summarization).

  • Set responseQualityScore if you have human or automatic scoring to surface low-quality responses.


🛠️ Example Usage Metadata Object

{
  "traceId": "session-38274",
  "taskType": "summarize-discharge-notes",
  "organizationId": "brighthealth-clinops",
  "subscriptionId": "clinical-tier-2",
  "productId": "ehr-summary",
  "agent": "gpt-4-discharge",
  "responseQualityScore": 0.94,
  "totalCost": 0.0215,
  "subscriber": {
    "id": "nurse.a57",
    "email": "[email protected]",
    "credential": {
      "name": "EHR Key – Nurse Station A",
      "value": "pk-ehra57"
    }
  }
}

Direct API Integration

Our API integration documentation for AI metering is available here. An example of the API structure to send metering data is shown below.

Many of the fields shown below are optional to demonstrate the possibilities for metadata enrichment. View the complete API documentation using the link above to verify required vs. optional fields.

curl -vX POST "https://api.dev.hcapp.io/meter/v2/ai/completions" \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'x-api-key: hak_your_key' \
     --data '

{
  "stopReason": "END",
  "costType": "AI",
  "isStreamed": true,
  "taskType": "discharge-summary",
  "agent": "clinical-summary-agent",
  "operationType": "CHAT",
  "inputTokenCount": 200,
  "outputTokenCount": 500,
  "reasoningTokenCount": 0,
  "cacheCreationTokenCount": 0,
  "cacheReadTokenCount": 0,
  "totalTokenCount": 700,
  "organizationId": "brighthealth-clinic",
  "productId": "ehr-integration",
  "subscriber": {
	  "id": "subscriberId-nurse-a57",
	  "email": "[email protected]",
	  "credential": {
	    "name": "EHR Access Token",
	    "value": "pk-ehra57"
	    }
  },
  "model": "gpt-3.5-turbo",
  "transactionId": "4yU2vUKQQE2lv7TWB6F3U5C05at5J2D",
  "responseTime": "2025-06-16T22:35:39.592Z",
  "requestDuration": 2400,
  "provider": "OpenAI",
  "requestTime": "2025-06-16T22:35:34.592Z",
  "completionStartTime": "2025-06-16T22:35:39.592Z",
  "timeToFirstToken": 10200
}
'

Last updated

Was this helpful?