LogoLogo
  • AI FinOps
    • ✨Revenium: AI FinOps
  • 🚀Quick Start Guide
  • 💹AI Analytics
  • ❗Cost & Performance Alerts
  • 📜System & Transaction Logs
  • 🗣️Customer & Subscriber Management
    • 🏢Organizations
    • 👥Subscribers
    • 🔑Subscriber Credentials (AI)
  • AI & API Monetization
    • Getting Started
      • Building a Usage-Based Product in Revenium
      • Setting Up & Using API Analytics & Observability
      • Setting Up & Using Product Analytics
      • Sending Data to Revenium's Metering API
      • Key Concepts & Relationships
    • Connect Your Data
      • cURL Commands for Testing
      • Container-Native Metering
      • Kong
        • Kubernetes Installation
      • Salesforce
        • Revenium Unmanaged Package
          • Anypoint API Experience Hub (AEH)
            • Anypoint API Experience Hub Unmanaged Package Post Installation Instructions
          • Anypoint Community Manager (ACM)
            • Anypoint Community Manager Package Post Installation Instructions
        • Revenium Lightning Web Components
          • Add Components to Experience Cloud site
          • Drop-In Storefront
          • Product Card
          • Product Card (Anypoint)
          • Product Checkout
          • Product Details Button
          • Usage History
          • API Access Requester
      • MuleSoft
        • Metering Policy Configuration
        • Offline Metering Policy Configuration
        • Anypoint API & API Group Synchronization
        • Revenium Connector
        • Disable Default Anypoint Community Manager (ACM) Email Notifications
      • Gravitee
      • Istio
      • Envoy
      • AWS API Gateway
      • Python & Django
      • Golang
      • Spring Boot
      • .Net
      • NodeJs
      • Java/JVM
      • Snowflake
      • Azure API Management
      • IBM
      • Custom Integrations Using Metering Beacons
        • JWT Enrichment
      • Offline Metering via Log Parsing
    • Sources
      • Metering Elements
      • Alerts
        • Alert History
    • API Keys
    • Products & Pricing
      • Product Lines
      • Pricing Rules
        • Revenium Scripting Language
          • RSL Reference
        • Execution Logs
      • SLA Definitions
      • SLA Violation Review
    • Customers
      • Customers
      • Subscribers
      • Subscriptions
      • Subscribers Credentials
      • Subscribers Notifications
    • Billing and Invoicing
      • Manage Refunds
    • Analytics
      • Revenue Analytics
      • Product Analytics
        • Custom Reports (Products)
      • Subscriber Analytics
        • New Subscribers
        • (Daily/Weekly/Monthly) Active Subscribers
        • Most Engaged Subscribers & Customers
        • Historical Usage
      • API Analytics
        • Performance & Availability
        • Compare Periods
        • Traffic by Geography
        • Advanced Search
        • Custom Reports
    • Profile
      • Profile
      • Revenium API Documentation
    • Settings
      • Revenium Users & Organizations
        • Access Permissions by User Type
      • Revenium Subscription
      • Revenium Organizations
      • Notification Templates
      • Transactions Logs
        • Analytics Transaction Log
        • Product Transaction Log
        • Subscription Audit Log
        • No Code Transaction Testing
      • Integrations
        • Data Sync
        • Export Configurations
        • Notification Providers
        • Payment Configurations
          • Customer VAT ID Support
        • ERP Configurations
        • External Integration Logs
        • Identity Providers
      • System Logs
      • Default Configuration Limits
Powered by GitBook

© Revenium - www.revenium.io

On this page
  • Connect in 5 Minutes or Less
  • You're Connected!
  • Advanced Config
  • Example Configuration using OpenAI
  • Additional Middleware

Was this helpful?

Quick Start Guide

Last updated 4 days ago

Was this helpful?

Connect in 5 Minutes or Less

  1. Choose your implementation method.

    1. Recommended: Install one of Revenium's middleware libraries () 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 .

  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

Remember, the latest configuration scripts can always be found in the 'get connected' page in the Revenium app. From within the app, you can copy the exact code required to install the middleware and execute a sample script with your account's API key.

Install Middleware

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": "user@example.com",
        # "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)

Additional Middleware

In addition to , Revenium provides libraries for , , and (with more on the way soon!). The latest versions are always available on . Need something else? !

🚀
i.e. these for python
metering API
openAI
LiteLLM
ollama
anthropic
Revenium's page in PyPi
Let us know