Install the X-Ray SDK using pip:
pip install xray-sdk 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.
Install the X-Ray SDK using pip:
pip install xray-sdk 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 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.
Configure the SDK via environment variables or programmatically with xray.init():
| Variable | Default | Description |
|---|---|---|
XRAY_ENDPOINT | https://api.xray.dev | API endpoint URL |
XRAY_DISABLED | false | Disable all tracing |
XRAY_SAMPLE_RATE | 1.0 | Fraction of runs to trace |
XRAY_TOP_K | 10 | Candidates to capture per step |