Proprietary SDK for Revgate services
Project description
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 mainRevgateclient and key functions.revgate.client: Contains theRevgateclass 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 -protoorjson(default:proto).REVGATE_OTEL_EXPORT_MODE: Span export mode -batchorsimple(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:
-
Install build tools:
pip install build
-
Run the build:
python -m build
This creates a
dist/directory containing the.whland.tar.gzfiles. -
Install the built wheel:
pip install dist/*.whl # Note: Validates that the package installs correctly.
Publishing (Manual)
To verify the upload or publish manually:
-
Install Twine:
pip install twine
-
Upload:
twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file revgate_python-0.1.0b2.tar.gz.
File metadata
- Download URL: revgate_python-0.1.0b2.tar.gz
- Upload date:
- Size: 42.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af3e32bac37dbfe4576ef328bb8d6d992d6cee7e1d109c94c0ce9dd74a8d346f
|
|
| MD5 |
ea023fa4282cefbf1b54381451639b8a
|
|
| BLAKE2b-256 |
45decbce26f0e722c5855f58b6493566bf3885c9d195c71725a1c6b726674413
|
Provenance
The following attestation bundles were made for revgate_python-0.1.0b2.tar.gz:
Publisher:
publish.yml on Revgate/revgate-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
revgate_python-0.1.0b2.tar.gz -
Subject digest:
af3e32bac37dbfe4576ef328bb8d6d992d6cee7e1d109c94c0ce9dd74a8d346f - Sigstore transparency entry: 1497800672
- Sigstore integration time:
-
Permalink:
Revgate/revgate-python-sdk@525d8b1fedeec8cdadacfe17980da0c9eb4db8c8 -
Branch / Tag:
refs/tags/v0.1.0-beta.2 - Owner: https://github.com/Revgate
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@525d8b1fedeec8cdadacfe17980da0c9eb4db8c8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file revgate_python-0.1.0b2-py3-none-any.whl.
File metadata
- Download URL: revgate_python-0.1.0b2-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
454fa72543de5828d8d09c77c62da26e65a7e97bfe70a1bc2745e972a0500edd
|
|
| MD5 |
ee04781c8da4d8ea35d15efe03e087b0
|
|
| BLAKE2b-256 |
0ee1a73ba57c28f5e88979e85ca75e5ff24397573369b4a04cab747847e13153
|
Provenance
The following attestation bundles were made for revgate_python-0.1.0b2-py3-none-any.whl:
Publisher:
publish.yml on Revgate/revgate-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
revgate_python-0.1.0b2-py3-none-any.whl -
Subject digest:
454fa72543de5828d8d09c77c62da26e65a7e97bfe70a1bc2745e972a0500edd - Sigstore transparency entry: 1497800797
- Sigstore integration time:
-
Permalink:
Revgate/revgate-python-sdk@525d8b1fedeec8cdadacfe17980da0c9eb4db8c8 -
Branch / Tag:
refs/tags/v0.1.0-beta.2 - Owner: https://github.com/Revgate
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@525d8b1fedeec8cdadacfe17980da0c9eb4db8c8 -
Trigger Event:
release
-
Statement type: