Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

spect-track

Python tracing client for Spect.

Status

spect-track provides the core observer/session lifecycle, trace payload building, HTTP transport, local mode, and typed payload contracts.

Provider-specific wrappers are still in progress. For now, record spans manually around the SDK call you want to trace.

Install

uv add spect-track
# or
pip install spect-track

Usage

import asyncio
import time

from spect_track import ModelSpec, ObserverOptions, SendResult, SessionOptions, create_observer


async def main() -> None:
    started_at = time.time_ns() // 1_000_000
    observer = create_observer(
        ObserverOptions(
            organization_id="your-org-id",
            api_key="your-spect-api-key",
            provider="openai",
        )
    )
    session = observer.start_session(
        SessionOptions(
            model=ModelSpec(model_id="gpt-4.1", provider="openai"),
            name="openai.responses.create",
            start_time=started_at,
        )
    )

    session.start_span(
        name="system",
        kind="system",
        status="ok",
        start_time=started_at,
        messages=[{"role": "system", "content": "You are a helpful assistant."}],
    )
    session.start_span(
        name="user",
        kind="user",
        status="ok",
        start_time=started_at,
        messages=[{"role": "user", "content": [{"type": "text", "text": "Explain tracing."}]}],
    )

    response_started_at = time.time_ns() // 1_000_000
    text = "Tracing records the model call, transcript, tools, timing, and metadata."
    response_ended_at = time.time_ns() // 1_000_000

    session.start_span(
        name="openai.responses.create",
        kind="generate",
        status="ok",
        start_time=response_started_at,
        end_time=response_ended_at,
        model={"modelId": "gpt-4.1", "provider": "openai"},
        messages=[{"role": "assistant", "content": [{"type": "text", "text": text}]}],
    )

    await session.send(
        SendResult(
            text=text,
            response={"model": "gpt-4.1", "finishReasons": ["stop"]},
            start_time=response_started_at,
            duration=max(0, response_ended_at - response_started_at),
            end_time=response_ended_at,
        )
    )


asyncio.run(main())

Message Shape

Record transcript items on spans with messages. Timing belongs on spans, not messages.

  • System messages use content: str.
  • User and assistant messages can use text/content parts.
  • Tool calls/results should include both the span-level tool overlay and canonical message parts.
{"role": "system", "content": "You are a helpful assistant."}
{"role": "user", "content": [{"type": "text", "text": "Hello"}]}
{"role": "assistant", "content": [{"type": "reasoning", "text": "I should search first."}]}
{"role": "assistant", "content": [{"type": "tool-call", "toolCallId": "call_1", "toolName": "search", "input": {"query": "asthma"}}]}
{"role": "tool", "content": [{"type": "tool-result", "toolCallId": "call_1", "toolName": "search", "output": {"type": "json", "value": {"matches": 3}}}]}

Local Mode

payloads = []

observer = create_observer(
    ObserverOptions(
        organization_id="org_123",
        local=True,
        provider="openai",
        on_trace=payloads.append,
    )
)

Development

From the repo root:

cd python
uv sync
uv run --package spect-track ruff check packages/spect-track packages/playground
uv run --package spect-track ty check packages/spect-track
uv run --package spect-track pytest packages/spect-track/tests

Build

cd python
uv build --package spect-track

Metadata

Release files for spect-track 0.0.1a3

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

Source distribution (sdist)

Source distribution for spect-track 0.0.1a3
File Size Uploaded Provenance Actions
spect_track-0.0.1a3.tar.gz 8.2 kB Without provenance Details for spect_track-0.0.1a3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spect-track 0.0.1a3
File Interpreter ABI Platform Actions
spect_track-0.0.1a3-py3-none-any.whl Python 3 none any Details for spect_track-0.0.1a3-py3-none-any.whl

Total release size: 19.1 kB

Release files / spect_track-0.0.1a3.tar.gz

Download URL spect_track-0.0.1a3.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5be2ced2699ac57fb872f299c343fc7f8770fadfe81038d3cfd5e665e9ede4dc
BLAKE2b-256 checksum
How to use checksums
f71045eb04069b0235abe7f077b582e41c0ec4d532346b70b36c27645218b917
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / spect_track-0.0.1a3-py3-none-any.whl

Download URL spect_track-0.0.1a3-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4f1f2316620d6d39df1f08810e8329123758c6a0dec42960e4987285eb81f17
BLAKE2b-256 checksum
How to use checksums
80fbc213c990386b4496439903ea35653f037fe6cb93369f4b403066b98863ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for spect-track 0.0.1a3

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.

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