Skip to main content

Python SDK for Sepurux trace recording and uploads

Project description

Sepurux Python SDK

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

Install

pip install -e sdk

Quick start

from sepurux import SepuruxClient, sepurux_trace

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

with sepurux_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

SepuruxClient

SepuruxClient(base_url, api_key=None, project_id=None, timeout=30, sdk_header=None)

The SDK automatically sends X-Sepurux-SDK: py/<version> on requests. Use sdk_header only if you need to override it manually.

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 sepurux import sepurux_trace

with sepurux_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 sepurux 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:

  • SEPURUX_API_BASE_URL (default http://localhost:8000)
  • SEPURUX_UI_BASE_URL (default http://localhost:3000)
  • SEPURUX_API_KEY
  • SEPURUX_PROJECT_ID
  • SEPURUX_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.2.0 to trigger publish.
  • Or run the workflow manually from GitHub Actions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sepurux-0.2.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sepurux-0.2.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file sepurux-0.2.0.tar.gz.

File metadata

  • Download URL: sepurux-0.2.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sepurux-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2c67e5a0809e249c6e0828c355376ffa9e5eaa2683722b507fba52c2bce7f04b
MD5 2812363f507f9e99b76e3afce8081a5f
BLAKE2b-256 a3f692b53829165c5de363a5a2ee6ddb85aec7d26e258850676ea202cf30449c

See more details on using hashes here.

File details

Details for the file sepurux-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sepurux-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sepurux-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bcab3d095d1727ec30ab8b7d34ad2a3314c91c9db88204033d2514d83f2b543
MD5 817acdccad66a5cbe8d9ea7d101f1674
BLAKE2b-256 9901a6b35d5fe627f4a16cfeb57cddfe1bd7579ad6af25f496f0dade974e0b4a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page