PluvianAI Python SDK
Zero-config monitoring for LLM APIs. Automatically track all your OpenAI, Anthropic, and other LLM API calls without changing your code.
Installation
pip install pluvianai
Quick Start
Zero-Config Setup (Recommended)
import pluvianai
# Initialize with environment variables
pluvianai.init()
# That's it! All OpenAI calls are now automatically monitored
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)
Environment Variables
Set these environment variables:
export PLUVIANAI_API_KEY="your-api-key"
export PLUVIANAI_PROJECT_ID="123"
export PLUVIANAI_API_URL="https://api.pluvianai.com" # Optional
export PLUVIANAI_AGENT_NAME="my-agent" # Optional
Manual Initialization
import pluvianai
pluvianai.init(
api_key="your-api-key",
project_id=123,
agent_name="my-agent"
)
Agent Chain Tracking
To track a chain of API calls that belong to the same workflow:
import pluvianai
from openai import OpenAI
pluvianai.init()
client = OpenAI()
# Use context manager to group related calls into a chain
with pluvianai.chain("user-query-123", agent_name="data-collector"):
# All calls within this block will have the same chain_id
response1 = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Collect data"}]
)
response2 = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Analyze data"}]
)
# Both calls will be grouped under chain_id="user-query-123"
# You can view them in the Agent Chains page
Manual Tracking
If you prefer to track calls manually:
import pluvianai
import time
start_time = time.time()
# ... make your API call ...
latency_ms = (time.time() - start_time) * 1000
pluvianai.track_call(
request_data={"model": "gpt-4", "messages": [...]},
response_data={"choices": [...]},
latency_ms=latency_ms,
status_code=200,
agent_name="my-agent",
chain_id="user-query-123" # Optional: group related calls
)
Features
- Zero-config: Automatically patches OpenAI SDK
- Non-blocking: Doesn't slow down your application
- Error handling: Gracefully handles failures
- Agent tracking: Track different agents in your system
Tool calls & workflow structure (optional)
The zero-config patching focuses on LLM API calls (requests/responses, latency, tokens/cost when available).
If you want PluvianAI to reliably validate tool usage policies across any framework (custom tools, LangChain, n8n-style workflows, HTTP/DB/Slack/email actions) — especially tool results and strict ordering — you may need to add lightweight, explicit instrumentation in your code (for example, wrapping tool execution or emitting tool events).
This is intentional: tool execution typically happens outside the LLM client, so it cannot always be inferred from LLM API traffic alone.
License
MIT
Release files for pluvianai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pluvianai-0.1.0.tar.gz | 11.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pluvianai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.0 kB
Release files / pluvianai-0.1.0.tar.gz
| Download URL | pluvianai-0.1.0.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a57fa22579a93b208a4edf20bed90b9705d6b3486acb9babf738a640b361681c
|
|
BLAKE2b-256 checksum How to use checksums |
c2f9150c80ec69ca62bc7ad70186cba6c7d3a14398cad19e4c858263e804850b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / pluvianai-0.1.0-py3-none-any.whl
| Download URL | pluvianai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
184412a75df9a9890947406c3785c57ced6e411ff63add06cf42b72da11e24e1
|
|
BLAKE2b-256 checksum How to use checksums |
f1f0877b325c618cac3be7f4786753bbad62e1fdb4cb277b4a9739312434593a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|