Getting Started

Add ZenRay to your ML pipeline in under 5 minutes.

New to ZenRay? This guide walks you through installing the SDK and instrumenting your first pipeline.

Setup

1 Install the SDK pip install

Install the X-Ray SDK using pip:

pip install xray-sdk
2 Instrument Your Pipeline Add decorators

Add two decorators: @xray.pipeline for the entry point, and @xray.step for each processing stage.

import xray

# Connect to X-Ray (get your API key from the dashboard)
xray.init(endpoint="https://api.xray.dev", api_key="your-api-key")

@xray.pipeline("my-pipeline")
def process(query: str):
    results = retrieve(query)
    ranked = rank(results)
    return filter(ranked)

@xray.step("RETRIEVE")
def retrieve(query: str):
    # Your retrieval logic here
    return vector_db.search(query, limit=100)

@xray.step("RANK")
def rank(items):
    for item in items:
        score = model.predict(item)
        xray.score(item, score)  # Track scores
        item.score = score
    return sorted(items, reverse=True)

@xray.step("FILTER")
def filter(items):
    for item in items:
        if item.score < 0.5:
            xray.drop(item, "low_score")  # Track why items are dropped
            continue
        yield item
3 View in Dashboard Sign up + connect

Sign up for X-Ray and connect your pipeline:

# 1. Sign up at xray.dev
# 2. Create a new project
# 3. Copy your API key
# 4. Add to your code:
xray.init(api_key="your-api-key")

Open the dashboard to view your pipeline runs in real-time.

Configuration

Environment Variables Configure via env

Configure the SDK via environment variables or programmatically with xray.init():

VariableDefaultDescription
XRAY_ENDPOINThttps://api.xray.devAPI endpoint URL
XRAY_DISABLEDfalseDisable all tracing
XRAY_SAMPLE_RATE1.0Fraction of runs to trace
XRAY_TOP_K10Candidates to capture per step

Next Steps

Learn More Documentation