Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Revgate SDK

The Revgate SDK provides a simple interface for tracing, billing, and observing your AI applications. It supports both manual event tracking and automatic instrumentation for popular AI libraries.

1. SDK Structure

The SDK is organized into the following modules:

  • revgate: Top-level package exposing the main Revgate client and key functions.
  • revgate.client: Contains the Revgate class for managing the connection and accessing sub-clients (e.g., billing).
  • revgate.tracing: The core tracing module.
    • revgate.tracing.core: Handles OpenTelemetry (OTEL) integration and span management.
    • revgate.tracing.events: Defines custom event tracking (e.g., billing events).
    • revgate.tracing.autoinstrumentation: Provides automatic instrumentation for AI libraries.
  • revgate.logger: Centralized logging configuration.

2. Usage

Installation

Basic Installation (Core) Lightweight install with just the core dependencies.

pip install revgate-python

With Specific Integrations Install support for specific AI libraries to enable auto-instrumentation.

# For specific providers
pip install "revgate-python[openai]"
pip install "revgate-python[anthropic,langchain]"
pip install "revgate-python[google-genai]"

# For all supported integrations
pip install "revgate-python[all]"

Development Setup For contributors or local development, install in editable mode with all features.

# From the root of the repository
pip install -e ".[all]"

Auto-Instrumentation

Revgate can automatically trace calls to supported AI libraries like Google GenAI, OpenAI, Anthropic, and LangChain. This captures spans, prompts, completions, and token usage without manual instrumentation.

Example with Google GenAI:

import os
from revgate import auto_instrument, Revgate

# 1. Initialize Auto-Instrumentation
# This must be called before using the AI library.
# Supported libraries: "google-genai", "openai", "anthropic", "langchain"
auto_instrument(["google-genai"])

# 2. Use the AI library as usual
from google import genai

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
response = client.chats.create(model='gemini-1.5-flash').send_message("Hello!")

print(response.text)
# A trace is automatically generated and sent to the configured OTEL collector.

Manual Event Tracking (Billing)

For custom business logic or billing events that are not captured by auto-instrumentation, you can use track_event.

Example:

from revgate import Revgate

client = Revgate()

# Track a billable event
client.billing.track_event(
    name="llm_call",
    metadata={
        "model": "gemini-1.5-flash",
        "tokens": 150,
        "cost": 0.00015,
        "currency": "USD",
        "user_id": "user_123"
    }
)

# Track a signal (non-billable)
client.billing.track_event(
    name="tool_execution",
    metadata={
        "tool": "search_db",
        "status": "success"
    }
)

Configuration

The SDK uses environment variables for configuration:

  • REVGATE_ENABLED: Enable/disable tracing and event tracking (default: true).
  • REVGATE_BASE_URL: Revgate base URL (default: http://dev.revgate.com).
  • REVGATE_API_KEY: Your Revgate API key.
  • REVGATE_OTEL_EXPORTER_TYPE: OTLP exporter type - proto or json (default: proto).
  • REVGATE_OTEL_EXPORT_MODE: Span export mode - batch or simple (default: batch).
  • REVGATE_ENABLE_CONSOLE_LOGGING: Enable console span exporter for debugging (default: false).
  • REVGATE_LOG_LEVEL: Logging level (default: INFO).

3. Development & Release

Local Development

To set up the environment for development:

# Install in editable mode with all dependencies
pip install -e ".[all]"

Building the Package

To build the distribution files (wheel and source archive) locally:

  1. Install build tools:

    pip install build
    
  2. Run the build:

    python -m build
    

    This creates a dist/ directory containing the .whl and .tar.gz files.

  3. Install the built wheel:

    pip install dist/*.whl
    # Note: Validates that the package installs correctly.
    

Publishing (Manual)

To verify the upload or publish manually:

  1. Install Twine:

    pip install twine
    
  2. Upload:

    twine upload dist/*
    

Metadata

Release files for revgate-python 0.1.0b2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for revgate-python 0.1.0b2
File Size Uploaded Provenance Actions
revgate_python-0.1.0b2.tar.gz 42.8 kB With provenance Details for revgate_python-0.1.0b2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for revgate-python 0.1.0b2
File Interpreter ABI Platform Actions
revgate_python-0.1.0b2-py3-none-any.whl Python 3 none any Details for revgate_python-0.1.0b2-py3-none-any.whl

Total release size: 55.4 kB

Release files / revgate_python-0.1.0b2.tar.gz

Download URL revgate_python-0.1.0b2.tar.gz
Size 42.8 kB
Tags Source
SHA-256 checksum
How to use checksums
af3e32bac37dbfe4576ef328bb8d6d992d6cee7e1d109c94c0ce9dd74a8d346f
BLAKE2b-256 checksum
How to use checksums
45decbce26f0e722c5855f58b6493566bf3885c9d195c71725a1c6b726674413
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2026.

Transparency log

Release files / revgate_python-0.1.0b2-py3-none-any.whl

Download URL revgate_python-0.1.0b2-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
454fa72543de5828d8d09c77c62da26e65a7e97bfe70a1bc2745e972a0500edd
BLAKE2b-256 checksum
How to use checksums
0ee1a73ba57c28f5e88979e85ca75e5ff24397573369b4a04cab747847e13153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2026.

Transparency log

Security for revgate-python 0.1.0b2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for revgate_python-0.1.0b2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page