๐Ÿ—ฃ๏ธCustomer & Subscriber Management

In Revenium, the following hierarchy and nomenclature is used to manage internal or external customers, users, subscribers, and credentials / API keys.

Term
Usage
Middleware Parameter

Organizations can be either company names or internal business units. The organization object in Revenium supports various metadata fields to allow you to easily sync these objects to internal systems (typically CRM).

Example Values:

AcmeSoft (customer)

Finance (internal)

Organizations can be associated with one or many subscribers

organization_id

Subscribers are individuals who consume AI or digital products. The subscriber object contains their email address and name. Email addresses are used to identify the subscriber in API / middleware calls.

Example Values: [email protected]

Subscribers can be associated with one or many subscriber credentials.

subscriber.email, subscriber.id

Credentials contain unique identifiers used by subscribers to access services. In some use cases, it will be the email address of the subscriber, but it could also be an alias for different API keys used by internal developers or external customers, particularly when one subscriber could have multiple API keys and you wish to track usage for each credential separately. Example Values: key1-hubspot, key2-financeProject

subscriber.credential.name, subscriber.credential.value

Example API Call Incorporating Customer Data

import os
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

import openai
import revenium_middleware_openai

# Ensure REVENIUM_METERING_API_KEY & OPENAI_API_KEY are set in your .env file

response = openai.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {
            "role": "system",
            "content": "You are a helpful assistant."
        },
        {
            "role": "user",
            "content": "Please verify you are ready to assist me."
        },
    ],
    max_tokens=500,

     usage_metadata={
         "subscriber": {
           "id": "1473847563",
           "email": "[email protected]",
           "credential": {
             "name": "Engineering API Key",
             "value": "hak-abc123456"
           }
         },
         "organization_id": "Finoptic Labs",
         "subscription_id": "sub_gold_1234567890",
     },
)
print(response.choices[0].message.content)

Last updated

Was this helpful?