SDKsPython
Python SDK overview
Install and initialize the SuperPenguin Python SDK for per-request AI cost tracking.
The Python package wraps native provider clients and captures per-request cost metadata. Calls go directly to the provider; there is no proxy.
- Package: superpenguin on PyPI
- License: MIT
- Python: 3.9+
Install
pip install superpenguinOptional extras:
pip install "superpenguin[otel]" # OpenTelemetry trace correlation
pip install "superpenguin[deepgram]" # Deepgram STT
pip install "superpenguin[elevenlabs]" # ElevenLabs TTS
pip install "superpenguin[voice]" # Deepgram + ElevenLabs + LiveKit
pip install "superpenguin[google]" # Google Gemini (google-genai)Initialize and wrap
import superpenguin as sp
from openai import OpenAI
sp.init(api_key="sp_...")
client = sp.wrap(OpenAI(), metadata={
"customer_id": "cust_acme_123",
"feature": "doc_summary",
})
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)Every create() through the wrapped client is captured with provider, model, token or unit counts, estimated cost, and latency.
Architecture
Your code
| client = sp.wrap(OpenAI())
| client.chat.completions.create(...)
|
|-- Call goes directly to the provider (no proxy)
|
'-- SDK extracts usage from the response
'-- Batches events in a background thread
'-- POSTs to /api/sdk/ingest