Getting started

Quickstart

From a clean environment to a verified trace in your workspace in about five minutes.

1. Install

shell
uv add mv37-rollout# or: pip install mv37-rollout

The base package depends only on httpx and pydantic. If you are instrumenting a provider client, add the matching extra so the SDK can parse its responses:

shell
uv add "mv37-rollout[openai]"      # or [anthropic]

2. Get an API key

Create a project in your Rollout workspace and copy its API key. The SDK reads ROLLOUT_API_KEY from the environment by default, so the cleanest setup is to export it and pass nothing in code:

shell
export ROLLOUT_API_KEY="sk_rollout_..."export ROLLOUT_ENVIRONMENT="production"   # optional

3. Initialize a client

You can either create a Rollout client and pass it around, or call rollout.init() once to set up a global client that the module-level helpers and decorators route through. Both read the same options from arguments or the environment.

setup.py
from mv37.rollout import Rollout# explicit clientclient = Rollout(agent_name="support_agent", environment="production")# — or — one global client for the whole processimport mv37.rollout as rolloutrollout.init(agent_name="support_agent", environment="production")

Tip

If ROLLOUT_API_KEY is set, Rollout() and rollout.init() take no required arguments. Pass api_key=... explicitly only when you are not using the environment variable.

4. Send your first trace

A trace is one agent run. Open it with a with block, record the conversation with trace.message(...), wrap model calls in an llm span, and let the helper pull token usage straight off the response. The trace flushes automatically when the block exits.

first_trace.py
from mv37.rollout import Rollout, usage_from_openaifrom openai import OpenAIclient = Rollout(agent_name="support_agent")openai_client = OpenAI()with client.trace("support_agent", conversation_id="thread_123", user_id="cus_123") as trace:    trace.message(role="user", content="Where is my order?")    with trace.llm("openai.responses", model="gpt-4.1-mini") as span:        span.record_input({"messages": [{"role": "user", "content": "Where is my order?"}]})        response = openai_client.responses.create(model="gpt-4.1-mini", input="Where is my order?")        span.record_output(response)                 # pydantic responses serialize automatically        span.set_usage(**usage_from_openai(response)) # token counts off the response    trace.message(role="assistant", content="Your order has shipped.")    trace.feedback("thumbs_up", True)

5. Verify the connection

check() sends a diagnostic trace through the real ingest path and prints a one-line summary. It is the fastest way to confirm your key, network, and base URL are all working.

verify.py
client.check()# ✓ Rollout connected — 3 event(s) accepted

It also returns a CheckResult (ok, accepted, rejected, errors, message); pass verbose=False to silence the print and inspect the result yourself.

Next steps