🚀Quick Start Guide

Initial Connection

Installation Steps

  1. Choose your implementation method.

    1. Recommended: Install one of Revenium's middleware libraries (i.e. these for python) that can be integrated using a single line of code. (we're just wrapping up development on a complete set of NodeJS middleware as well)

    2. You can also create a direct integration using our metering API.

  2. Add the middleware into your current code with a single import line. Revenium's code will wrap your existing AI calls and begin metering immediately.

You're Connected!

Advanced Config

  1. Enhance your AI calls with additional metadata to enable powerful reporting by customer, by agent, by task, by product, by subscriber, and more.

  2. Set up spending & performance alerts in Revenium to avoid spending or performance surprises.

  3. Customize Revenium's standard dashboards as you see fit to provide the information you need at a glance.

Example Configuration using OpenAI

Install Appropriate Middleware for Your Use Case

pip install revenium-middleware-openai

Configure Environment Variables

export REVENIUM_METERING_API_KEY="YOUR_REVENIUM_KEY"
export OPENAI_API_KEY="YOUR_OPENAI_KEY"

Import Revenium Middleware to Existing Python Script

import openai

#the following line is the only required change to existing scripts
import revenium_middleware_openai 

response = openai.chat.completions.create(
    model="gpt-4",
    messages=[
        {
            "role": "system",
            "content": "You are a helpful assistant."
        },
        {
            "role": "user",
            "content": "What is the meaning of life?"
        },
    ],
    max_tokens=500,

    # Optional metadata to send to Revenium for 
    # advanced reporting
    # usage_metadata={
        # "trace_id": "conv-28a7e9d4",
        # "task_type": "summarize-customer-issue",
        # "subscriber_email": "[email protected]",
        # "subscriber_id": "subscriberid-1234567890",
        # "subscriber_credential_name": "engineering-api-key",
        # "organization_id": "my-customers-name",
        # "subscription_id": "startup-plan-Q1",
        # "product_id": "saas-app-gold-tier",
        # "agent": "support-agent",
    # },
)

print(response.choices[0].message.content)

Usage Metdata Schema

View the reference guide to see the list supported metadata across middleware packages.

Additional Middleware

📘 Complete list of supported middleware

Last updated

Was this helpful?