Skip to main content

Lightweight debugging SDK for multi-step AI pipelines.

Project description

X-Ray SDK (PyPI)

Install:

python3 -m pip install xray-sdk

Configure env (example):

export XRAY_API_URL=https://ai-agent-x-ray.onrender.com
export XRAY_API_KEY=your-xray-api-key

Or create a .env with those keys and the examples will load it via load_dotenv().

Basic use:

import os
from xray_sdk import XRayClient, XRayRun, XRayStep

client = XRayClient(
    os.getenv("XRAY_API_URL", "https://ai-agent-x-ray.onrender.com"),
    api_key=os.getenv("XRAY_API_KEY"),
)

run = XRayRun(
    pipeline_name="my_pipeline",
    description="Demo pipeline for keyword generation and search.",
    metadata={"ctx": "demo"},
    sample_size=20,
)

run.add_step(XRayStep(
    name="stage1",
    order=1,
    description="Generate search keywords from the user query.",
    inputs={
        "query": "phone case",
        "filters": {"min_rating": 4.0},
        "llm_prompt": "Generate 5 search keywords for the product query.",
    },
    outputs={
        "keywords": ["phone case", "iphone 15 case"],
        "candidates_count": 3,
    },
    reasons={
        "dropped_items": [
            {"id": "B002", "reason": "too expensive"},
        ]
    },
    metrics={
        "latency_ms": 120,
        "elimination_rate": 0.33,
        "model": "gpt-4o-mini",
        "temperature": 0.2,
        "prompt_tokens": 42,
    },
))

result = client.send(run)
print(result)

Client methods:

  • send(run, analyze=True) → POST /api/ingest
  • spool(run, spool_dir=".xray_spool") → save locally if API unavailable
  • flush_spool(spool_dir=".xray_spool") → replay newest spooled run
  • list_pipelines() → GET /api/pipelines
  • list_runs(pipeline=None, status=None, limit=50) → GET /api/runs
  • get_run(run_id) → GET /api/runs/<id>
  • get_analysis(run_id) → GET /api/runs/<id>/analysis
  • search_steps(step_name=None, pipeline=None, limit=50) → GET /api/search/steps

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

xray_sdk-0.1.5.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

xray_sdk-0.1.5-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file xray_sdk-0.1.5.tar.gz.

File metadata

  • Download URL: xray_sdk-0.1.5.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for xray_sdk-0.1.5.tar.gz
Algorithm Hash digest
SHA256 41163e3e55506f4711f2eb4ce2775865a59cecb74dd9b3a85b877a2fdadc915c
MD5 df98d6775f7bb7122d50e6d538831ba4
BLAKE2b-256 c8f57f1fe1de6609f7f27d14291ef95a868f85b0b7b898da3831804fb022a93f

See more details on using hashes here.

File details

Details for the file xray_sdk-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: xray_sdk-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for xray_sdk-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9d8827a4a6979212069bb2f70bfdd29279faa69f22567cf567614dd0040ca675
MD5 92344902e521f92e031a55c1b203ee4a
BLAKE2b-256 b60d71b363bc2c96cfcd2f5138a5a088af5bc1a6843edd454a4115052fc6c06c

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