Skip to main content

Crash Lab Python SDK

Python SDK for recording Crash Lab traces and uploading them to a Crash Lab API.

Install

pip install -e sdk

Quick start

from crashlab_sdk import CrashLabClient, crashlab_trace

client = CrashLabClient(
    base_url="http://localhost:8000",
    api_key="crashlab-dev-key",
    project_id="22222222-2222-2222-2222-222222222222",
)

with crashlab_trace("example_task", {"user_id": "u-123"}) as rec:
    rec.model_step("plan", {"goal": "create issue"}, output={"ok": True})
    rec.tool_call("jira.create_issue(commit)", {"summary": "SDK test"})
    rec.tool_result("jira.create_issue(commit)", {"issue_id": "OPS-123"})

trace_id = client.upload_trace(rec.to_trace())
print("trace_id:", trace_id)

API

CrashLabClient

CrashLabClient(base_url, api_key=None, project_id=None, timeout=30)

Methods:

  • upload_trace(trace: dict) -> str
  • create_campaign(name, mutation_set, eval_set, mutation_pack_id=None) -> str
  • start_run(trace_id, campaign_id, thresholds=None) -> str
  • get_run(run_id) -> dict

TraceBuilder

TraceBuilder outputs backend-compatible traces:

{
  "trace_version": "0.1",
  "source": "sdk",
  "task": {"name": "...", "input": {}},
  "events": []
}

Recorder

Use a context manager:

from crashlab_sdk import crashlab_trace

with crashlab_trace("task_name", {"input": "value"}) as rec:
    rec.model_step("name", {"foo": "bar"}, output={"ok": True})
    rec.tool_call("tool.name", {"arg": 1})
    rec.tool_result("tool.name", {"result": "ok"})
    rec.error(message="something happened", tool="tool.name")

Decorator

from crashlab_sdk import record_trace

@record_trace(client=client, campaign_id="<campaign_id>")
def run_business_logic(x: int) -> int:
    return x * 2

The decorator preserves the function return value and attempts to upload/start runs in the background path without interrupting normal execution.

Example script

See examples/sdk_demo.py.

python sdk/examples/sdk_demo.py

Optional environment variables:

  • CRASHLAB_API_BASE_URL (default http://localhost:8000)
  • CRASHLAB_UI_BASE_URL (default http://localhost:3000)
  • CRASHLAB_API_KEY
  • CRASHLAB_PROJECT_ID
  • CRASHLAB_CAMPAIGN_ID (if provided, script starts a run)

Publish to PyPI (CI)

This repository includes .github/workflows/sdk-publish-pypi.yml to publish the SDK directly to PyPI.

Setup:

  • Add PYPI_API_TOKEN in GitHub repository secrets.
  • Ensure the package version in sdk/pyproject.toml is new.

Release:

  • Push a tag like sdk-v0.1.1 to trigger publish.
  • Or run the workflow manually from GitHub Actions.

Metadata

Release files for crashlab-sdk 0.1.1

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

Source distribution (sdist)

Source distribution for crashlab-sdk 0.1.1
File Size Uploaded Provenance
crashlab_sdk-0.1.1.tar.gz 6.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for crashlab-sdk 0.1.1
File Interpreter ABI Platform
crashlab_sdk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.0 kB

Release files / crashlab_sdk-0.1.1.tar.gz

Download URL crashlab_sdk-0.1.1.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4fc29c461d6b7d290153daee8975a5be94b9ee6625b8e252f9dfdcad405e49fc
BLAKE2b-256 checksum
How to use checksums
ae4e7ee00360a43848f0392402b332bda49b2eaa968d7aefabb5d21cd5e05957
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / crashlab_sdk-0.1.1-py3-none-any.whl

Download URL crashlab_sdk-0.1.1-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3fe0e0aa0189e4af0373993df53be7fb15d4e569bc86ecb1d50531027fd4b641
BLAKE2b-256 checksum
How to use checksums
7cacb5debd03fe4ec91d535d48954705f7b7c05c0b048c767a86fe4af14c27de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for crashlab-sdk 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.1 This release

2 release files No 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