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.4.tar.gz (9.8 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.4-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xray_sdk-0.1.4.tar.gz
  • Upload date:
  • Size: 9.8 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.4.tar.gz
Algorithm Hash digest
SHA256 fdd474dddce87638c383d7bc4ed38603caf59fd4f493a20a91cb570bab07a530
MD5 29a8a644a1a9f9342f500e9a534644da
BLAKE2b-256 61ba8778ef71d0a300f0adebed8720b619dce0c8a1ed021207c260d9ea917f29

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xray_sdk-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 77842af2703bf80f525ad85bd40b97b5662b52c01bec350db038b7bb659ccb8b
MD5 305c26232734d05a42d16abea6c28681
BLAKE2b-256 bd418f019cc2d8fb170632c04b39357d5c6883e011602577084fad33366aaede

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