All posts
TUTORIAL5 min read

Trace your first LLM call in 5 lines

The Currai team, EngineeringMay 12, 2026

The fastest way to understand Currai is to send one trace. There is no agent to deploy, no collector to run, and no schema to define — install the SDK, authenticate, and wrap a call.

1. Install and authenticate

One dependency, no native build step. Authenticate with a public / secret key pair scoped to your project.

# pip install currai   (or:  npm i currai)
from currai import Currai

currai = Currai(public_key="pk-lf-...", secret_key="sk-lf-...")

2. Wrap a call

A trace is the unit of work; a generation is a single model call inside it. Currai records the prompt you sent, the completion you got back, the model and its parameters, and how long it took.

trace = currai.trace(name="chat-turn", user_id="user-1")

gen = trace.generation(
    name="openai.chat.completions",
    model="gpt-4o-mini",
    input=messages,
)
reply = client.chat.completions.create(model="gpt-4o-mini", messages=messages)
gen.end(output=reply.choices[0].message.content)

3. Flush before you exit

Traces are batched and flushed in the background so instrumentation never blocks a request. In a short-lived process — a script or a serverless function — call flush so traces are sent before the process exits.

currai.flush()              # sync
# await currai.flush_async()  # async runtimes

From here, attach token usage to see cost computed for you, nest spans to capture a RAG pipeline, or pass a session id to stitch a multi-turn conversation together. Each is a single extra argument away.