Skip to main content

Multi-provider LLM batch prediction library

Project description

relay

A unified, provider-agnostic Python library for submitting, managing, and downloading results from large-scale LLM batch prediction jobs across Anthropic, OpenAI, Google, and XAI.

Installation

# Minimal
pip install relay

# All providers + full feature set
pip install relay[all]

# Individual providers
pip install relay[anthropic]
pip install relay[openai]
pip install relay[google]
pip install relay[xai]

Quickstart

import asyncio
from relay import BatchClient, BatchRequest, BatchConfig, Message

requests = [
    BatchRequest(id=f"req-{i}", messages=[Message(role="user", content=f"Summarize: {text}")])
    for i, text in enumerate(my_texts)
]

config = BatchConfig(provider="anthropic", model="claude-opus-4-5")

async def main():
    async with BatchClient() as client:
        job = await client.submit(requests, config)
        results = await client.wait_and_download(job.id)
    return results

results = asyncio.run(main())

Features

  • Provider-agnostic API — switch providers with a single config change
  • Resilient job state — jobs survive process crashes; state is persisted to SQLite
  • Smart caching — identical (prompt, model, params) tuples are never sent twice
  • Cost estimation — token count and cost estimate before every submission
  • Budget controls — configurable warn, confirm, and hard-limit thresholds
  • Fan-out — send the same request to multiple providers simultaneously
  • Multiple export formats — JSONL, CSV, Parquet, HuggingFace Dataset
  • Terminal dashboard — live TUI for monitoring jobs, costs, and cache
  • Web dashboard — lightweight FastAPI UI for remote monitoring
  • Observability — Prometheus, OpenTelemetry, and JSONL metrics exporters

Provider Compatibility

Provider Model family Batch API Streaming Fan-out
Anthropic Claude 3/4 Yes No Yes
OpenAI GPT-4o, o-series Yes No Yes
Google Gemini 1.5/2.0 Yes No Yes
XAI Grok Yes No Yes

CLI

# Submit a batch job
relay submit requests.jsonl --provider anthropic --model claude-opus-4-5

# Submit and wait for results
relay run requests.jsonl --provider openai --model gpt-4o --output results.jsonl

# Dry-run cost estimate
relay estimate requests.jsonl --provider anthropic --model claude-opus-4-5

# List and monitor jobs
relay jobs list
relay jobs status <job-id>

# Export results
relay export <job-id> --format parquet --output results/

# Cache management
relay cache stats
relay cache vacuum

# Spending report
relay costs today

Documentation

See the spec.md for the full technical specification and API reference.

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

relay_llm-0.3.0.tar.gz (156.5 kB view details)

Uploaded Source

Built Distribution

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

relay_llm-0.3.0-py3-none-any.whl (163.6 kB view details)

Uploaded Python 3

File details

Details for the file relay_llm-0.3.0.tar.gz.

File metadata

  • Download URL: relay_llm-0.3.0.tar.gz
  • Upload date:
  • Size: 156.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for relay_llm-0.3.0.tar.gz
Algorithm Hash digest
SHA256 53ac3fb6a6e25282ac09538f77436836ef6f514890eacb83d05eb13eb9cfd68f
MD5 bfd5ef0ecc5bca462e0c8a84680d97f9
BLAKE2b-256 8265c9ea474b067934a3099e742f000515f883a304fe395d2355c03a588b6673

See more details on using hashes here.

File details

Details for the file relay_llm-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: relay_llm-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 163.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for relay_llm-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a58586b87d3f266c41d2df1aa3ffa26b26d5423db95013b700565d60d29f4558
MD5 f422b2c42333575c49b30df888e3a75b
BLAKE2b-256 43ee5923bca54f11bc03b5fc0910fee5ff4ca4a5e9a07e43f6d7015799f196bc

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