Skip to main content

Traccia

The AI agent control plane. Observe, evaluate, govern and prove what your agents do.

An open-source Python SDK for tracing, evaluations, prompt management, and runtime governance, built on OpenTelemetry.

PyPI Python Downloads License GitHub stars

Docs · Quickstart · TypeScript SDK · Free account · Changelog

  • Observe. init() traces every OpenAI, Anthropic, Gemini and Groq call, with tokens and cost on each span. Send traces to Traccia or to any OTLP backend.
  • Evaluate. Score your agent on a dataset with evaluate(), locally or as a saved experiment, and fail a pull request when quality falls or cost or latency goes over your limit. Version prompts and load them at runtime.
  • Govern. Check each LLM and tool call before it runs: stop an agent that overspends, loops or calls the wrong tool.
  • Prove. Keep evidence for the EU AI Act and HIPAA in the Compliance Hub.

One agent run in Traccia: duration, cost, tokens, LLM and tool calls, and the span timeline
One agent run in Traccia: cost, tokens, every LLM and tool call, and how long each took.

Quickstart

No Traccia account needed. You need an OpenAI API key for this example.

1. Install

pip install traccia openai
export OPENAI_API_KEY="sk-..."

2. Trace your first call

from openai import OpenAI
from traccia import init, observe

init(use_otlp=False, enable_metrics=False, enable_console_exporter=True)  # print spans in your terminal
# init(endpoint="http://localhost:4318/v1/traces")  # or send them to Jaeger, Tempo, SigNoz...
# init()  # or to Traccia: set TRACCIA_API_KEY from app.traccia.ai

client = OpenAI()  # patched by init()

@observe()
def answer(question: str) -> str:
    resp = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": question}],
    )
    return resp.choices[0].message.content

answer("What is OpenTelemetry?")

3. See the trace

Each LLM span records the model, tokens, cost, prompt, completion and latency. It prints in your terminal, shows up in your OTLP backend (Jaeger, Grafana), or appears under Traces in Traccia like the run above.

Evaluate your agent

Run your agent over a small dataset and score every answer. This runs locally, with no Traccia account:

from traccia import evaluate

result = evaluate(
    "trivia-check",
    data=[
        {"input": {"question": "What is the capital of France?"}, "expected": "Paris"},
        {"input": {"question": "What is 12 * 12?"}, "expected": "144"},
        {"input": {"question": "Who wrote Hamlet?"}, "expected": "Shakespeare"},
    ],
    task=lambda input: answer(input["question"]),  # answer() from the quickstart
    scorers=["contains"],  # also exact_match, json_valid, or your own function
    persist=False,         # keep it local
)
print(result.summary())

If one of the three answers misses, it prints:

Experiment: trivia-check
Items: 3
Pass rate: 0.6666666666666666
Scored: 3
Errors: 0
Persisted: no (local-only)

Drop persist=False and the run is saved as an experiment in Traccia, where you can compare it with the last run side by side and score with an LLM judge. In CI, traccia eval fails the job when quality, cost or latency misses the bar you set (CI evals, GitHub Action). More: Evaluate.

Version your prompts

Keep prompts in the Traccia prompt registry, where each version is fixed once saved and the production label marks the one to serve. Your code loads whatever version holds the label:

from traccia import load_prompt

prompt = load_prompt(
    "support-reply",
    label="production",
    fallback={"type": "chat", "messages": [  # used if Traccia can't be reached
        {"role": "system", "content": "You answer billing questions for {{company}}."},
        {"role": "user", "content": "{{question}}"},
    ]},
)
messages = prompt.compile(company="Acme", question="Why was I charged twice?")

compile() fills in the {{variables}} and records the prompt name and version on the current span, so each trace shows which prompt produced it. Prompts are cached, and the fallback keeps your agent running if the registry is out of reach. More: Prompts.

Stop a runaway agent

@observe records what happened. @govern also decides whether the next call is allowed to happen. Policies live in the Traccia app, so you can change a limit without a deploy.

flowchart LR
    A["Your agent<br/>(@govern)"] --> B{"Policy check<br/>before the call"}
    B -->|Allow| C["LLM or tool runs"]
    B -->|Reshape| D["Runs on a cheaper model<br/>or with fewer tokens"]
    B -->|Deny| E["AgentBlockedError<br/>provider never called"]
    B -->|Hold| F["ApprovalPending raised<br/>approval queued"]
    C --> G["Spans over OTLP"]
    D --> G
    G --> H["Traccia"]
    G --> I["Or any OTLP backend:<br/>Tempo, Jaeger, Zipkin, SigNoz"]

In the Traccia app, create a Loop Cap policy with a maximum of 3 tool calls per run, set it to Block, and copy your API key.

from traccia import init, observe, govern, AgentBlockedError

init(api_key="...", agent_id="research-agent")  # API key from app.traccia.ai

@observe(name="web_search", as_type="tool")
def web_search(query: str) -> str:
    return f"results for {query}"

@govern(name="run_agent")
def run_agent(topic: str) -> None:
    while True:  # a bug: the agent never decides it has enough
        web_search(topic)

try:
    run_agent("agent observability")
except AgentBlockedError as exc:
    # The 4th search is denied before it runs.
    print(exc.reasons, exc.decision_id)

The same wrapper runs the other policies, for example:

  • Spend Cap stops a model call that would go over your USD budget, or moves it to a cheaper model.
  • Refund Guard stops a refund over your limit. For a middle amount, @govern raises ApprovalPending and queues the request for a person to approve.
  • High-Risk Tool stops a tool you name, such as delete_account.

See all policies. Each one runs in Observe (log a match), Warn (alert) or Block (stop the call) mode, so you can watch what a policy would stop before you turn it on.

If Traccia can't be reached, the check blocks the call by default. You can let calls through instead under Settings → Policy Enforcement, or locally with init(policy_fail_mode="open"). See Governance in the SDK.

Can't add the SDK? Use the Gateway

For an agent you can't change, such as a closed-source tool or an n8n workflow, point its OpenAI, Anthropic or Gemini client at the Traccia Gateway: change the base URL and add two Traccia headers. You keep your own provider key. The Gateway checks each model call, but it can't see tools or the rest of the run:

SDK (@govern) Gateway
Spend Cap, Model Boundary Yes Yes
Loop Cap, tool guards (Refund Guard, High-Risk Tool, ...), Prompt Pin and the other SDK-only policies Yes No
What the trace shows The whole run: tools, nested steps, every call One span per model call

Use one or the other for a given call, not both. Guides for LiteLLM, the Vercel AI SDK, n8n and more are in the Gateway docs.

Works with

What needs an account

Without an account With a Traccia account
Tracing, to the console or any OTLP backend Yes Yes, plus the Traccia app
Local evals with evaluate(persist=False) Yes Yes
Saved experiments, comparisons, LLM-judge scorers No Yes
Prompt registry (load_prompt) Fallback only Yes
Runtime policies (@govern) No Yes
The Gateway, human approval, the Compliance Hub No On paid plans

There is a free plan. See pricing.

Docs

Topic Where
Install and first trace Quickstart
@observe, spans, async, errors The observe decorator
evaluate(), scorers and experiments Evaluate
load_prompt and the prompt registry Prompts
@govern, policy checks, fail mode Governance in the SDK
Guardrail detection Guardrails
Cost estimation and pricing overrides Pricing
OpenTelemetry metrics Metrics
Multi-agent services and parallel runs Multi-agent · Parallel runs
traccia.toml and environment variables Configuration
traccia doctor, check, pricing, eval CLI
Full API Python SDK reference
Something not working Troubleshooting
Docs for your coding agent traccia.ai/llms.txt

Contributing

Bug fixes, integrations and examples are welcome. See CONTRIBUTING.md, and open an issue or a discussion first for anything large.

git clone https://github.com/traccia-ai/traccia-py.git
cd traccia-py
python -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
pytest tests/ -v

If Traccia caught a bad call for you, a star helps other people find it.

Read this far? Come build Traccia with us.

If you want to work on Traccia full time, skip the cover letter. Email founders@traccia.ai with one specific thing: a trace the SDK got wrong, a policy you needed and couldn't build, or a part of this code you would rewrite and how.

"I'm passionate about AI" gets archived. A link to your pull request gets a reply.

License

Apache 2.0. Built on OpenTelemetry.

Metadata

Release files for traccia 0.1.35

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traccia 0.1.35
File Size Uploaded Provenance Actions
traccia-0.1.35.tar.gz 368.4 kB With provenance Details for traccia-0.1.35.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for traccia 0.1.35
File Interpreter ABI Platform Actions
traccia-0.1.35-py3-none-any.whl Python 3 none any Details for traccia-0.1.35-py3-none-any.whl

Total release size: 675.5 kB

Release files / traccia-0.1.35.tar.gz

Download URL traccia-0.1.35.tar.gz
Size 368.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cde849040a56569c207b64193a879a2a3e8b3d1b2f19603498d52fedda0a1830
BLAKE2b-256 checksum
How to use checksums
74e8cbdaa36d79fd4d45311c58a1e44c99398c67d42308d4f5dcb525a53bcaa0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / traccia-0.1.35-py3-none-any.whl

Download URL traccia-0.1.35-py3-none-any.whl
Size 307.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7b869ad06c1532251cc1b470d3e3e80bb7e1d6dbb60ab5a0a64a9ab801c5def
BLAKE2b-256 checksum
How to use checksums
a235f1b1b17e5e443aed346b6dfcdf1f9a0bf18e5aa0ed32c60847ad03e91415
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for traccia 0.1.35

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for traccia-0.1.35.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.35 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page