Best viewed on desktop
The Playground is a multi-pane code environment designed for larger screens. Open it on your laptop or desktop for the full experience.
ElectriPy AI · Playground
Pick a pattern. Read the code. See it run — no setup required.
Running in production?ElectriPy Cloud →
Basic AI Runtime
beginnerCalling an LLM directly means zero visibility, zero retry logic, and a single point of failure. The ElectriPy runtime wraps every call in a fully instrumented, policy-aware execution context.
L04 Model Runtime
LLM GatewayRuntime TracingToken Counting
code
$ pip install electripy-ai
from electripy import ai
response = await ai.complete(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Explain AI observability in 30 words."}],
)
print(response.content)
print(f"Tokens used: {response.usage.total_tokens}")
output
✦ Simulated outputNo API key or network required
output
{
"content": "AI observability means tracking every LLM call—inputs, outputs, latency, cost, and errors—so you can debug, optimise, and govern AI reliably in production.",
"usage.prompt_tokens": 24,
"usage.completion_tokens": 31,
"usage.total_tokens": 55,
"model": "gpt-4o-mini",
"latency_ms": 312
}runtime events
- 1Request received by runtime
- 2Policy pre-flight checkALLOW
- 3LLM call dispatched
- 4Response received31 tokens
- 5Span closed — latency 312 ms
Key takeaway: Every call goes through policy, tracing, and cost tracking automatically — no extra code required.
Why it matters: Your team gets full visibility into every AI decision — what was asked, what came back, how long it took, and what it cost. No more black boxes, no more surprise bills.