Python SDK
Instrument Python apps with the shipgauge package
The Python SDK mirrors the Node workflow: wrap OpenAI (or record manually) with a stable feature_id.
Install
From PyPI when published, or from the SDK repo / monorepo package:
pip install shipgauge
# or editable during development:
# pip install -e packages/python
Initialize and wrap OpenAI
from shipgauge import ShipGauge
from openai import OpenAI
sg = ShipGauge(
api_key="sg_ingest_...",
project_id="your-project-uuid",
base_url="https://shipgauge.dev",
environment="production", # or os.environ.get("VERCEL_ENV", "development")
)
client = sg.wrap_openai(OpenAI(), default_feature_id="chat")
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
Pass customer_id / deployment on record() for Margin and deploy views:
sg.record(
feature_id="chat",
model="gpt-4o-mini",
input_tokens=100,
output_tokens=40,
customer_id="cus_123",
deployment="abc1234",
)
OpenAI-compatible providers:
client = sg.wrap_compatible(OpenAI(base_url="...", api_key="..."), default_feature_id="chat")
Optional OTLP export (best-effort, no OpenTelemetry SDK):
from shipgauge import ShipGauge, OtelExporterConfig
sg = ShipGauge(
api_key="...",
project_id="...",
otel=OtelExporterConfig(endpoint="https://otel.example/v1/traces"),
)
Manual tracking
with sg.track(
feature_id="summarize",
model="gpt-4o-mini",
input_tokens=500,
output_tokens=120,
):
# your LLM call
...
Notes
- Sends metadata only — not prompt or completion text.
- Prefer the same
feature_idstrings as Node and your eval suites.
Verify
Generate traffic, then open Overview for the project.