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.3.tar.gz (8.6 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.3-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for xray_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 fbc3e02e0077b04ea138fba6d1961a48af166e559e1936dccbb9db3030be58cc
MD5 7d1ec4cf3e3fa394cb5a210fa66f87c9
BLAKE2b-256 068593fa0f8bd9db647603646291dbaa0832e6ddfa4b99721c13cabab63419fd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for xray_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2cc9d89046ff41ca8b910208e002ca54175aff62660e01dbf6b83920c90fe6db
MD5 91fd6f328e58bf01cd6004af6fcc0a86
BLAKE2b-256 aab2a20e7d1c4c09196e9cb856929ae293ccd467b94d5f46f3535176e2cddd40

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