Skip to main content

RustyRAG Python SDK

Python client for the RustyRAG API — fast, minimal RAG-as-a-Service.

Install

pip install rustyrag

Note: the package installs as rustyrag, but the import is capitalized: from RustyRAG import rustyrag.

Authentication

Every request authenticates with your RustyRAG API key (rr_sk_...). Create one in your dashboard at rustyrag.ai — it's the only credential the SDK needs (email verification is just for creating your account; the SDK never uses it).

Pass the key directly:

from RustyRAG import rustyrag

client = rustyrag(api_key="rr_sk_...")

Or set it once in the environment and omit it in code (recommended — keeps secrets out of source):

export RUSTYRAG_API_KEY="rr_sk_..."
client = rustyrag()  # reads RUSTYRAG_API_KEY automatically

The key is sent as Authorization: Bearer rr_sk_... on every request. A missing key raises ValueError; an invalid one raises AuthenticationError (HTTP 401).

Quick start

from RustyRAG import rustyrag

client = rustyrag(api_key="rr_sk_...")

# Upload a document
resp = client.upload("report.pdf")
client.wait_for_upload(resp.task_id)

# Ask a question
answer = client.answer("What is the main conclusion?")
print(answer.message)
print(answer.sources)
print(answer.timing)  # Timing(ttft_ms=148, total_ms=230)

Streaming

for chunk in client.answer("Summarize the key points", stream=True):
    if chunk.text:
        print(chunk.text, end="", flush=True)
    if chunk.timing:
        print(f"\nTTFT: {chunk.timing.ttft_ms}ms")

All methods

client.health()                          # GET  /v1/health
client.usage()                           # GET  /v1/usage
client.models()                          # GET  /v1/llms
client.upload("file.pdf")                # POST /v1/upload
client.poll_upload(task_id)              # GET  /v1/uploads?task_id=...
client.wait_for_upload(task_id)          # Poll until complete
client.answer("question")               # POST /v1/answer
client.answer("question", stream=True)  # POST /v1/answer (SSE)
client.search("query", limit=5)         # POST /v1/search

Options

# Override model/provider per request
client.answer("question", model="llama3.1-8b", provider="groq")

# Skip reranker for faster TTFT (omit to use your account's Search preference)
client.answer("question", skip_reranker=True)

# Augment the answer with live web results (plan-gated)
answer = client.answer("question", web_search=True)
for w in answer.web_sources:
    print(w.title, w.url)

# Ground the answer/search in specific collections
client.answer("question", collection_ids=["<uuid1>", "<uuid2>"])
client.search("query", collection_ids=["<uuid1>"])

# Stream + skip reranker
client.answer("question", stream=True, skip_reranker=True)

Async

from RustyRAG import AsyncRustyRAG

async with AsyncRustyRAG(api_key="rr_sk_...") as client:
    answer = await client.answer("What is the main conclusion?")
    print(answer.message)

    # Async streaming
    async for chunk in await client.answer("Summarize", stream=True):
        if chunk.text:
            print(chunk.text, end="")

Configuration

client = rustyrag(
    api_key="rr_sk_...",                              # or set RUSTYRAG_API_KEY env var
    base_url="https://api.rustyrag.ai",               # or set RUSTYRAG_BASE_URL env var
    default_model="qwen-3-235b-a22b-instruct-2507",   # default
    default_provider="cerebras",                       # default
    timeout=120.0,                                     # seconds
)

Error handling

from RustyRAG import (
    rustyrag,
    AuthenticationError,
    BadRequestError,
    ForbiddenError,
    NotFoundError,
    ConflictError,
    QuotaExceededError,
    ServiceUnavailableError,
    NetworkError,
)

client = rustyrag(api_key="rr_sk_...")

try:
    answer = client.answer("question")
except AuthenticationError:
    print("Invalid API key")             # 401
except ForbiddenError:
    print("No access to that collection") # 403
except NotFoundError:
    print("Collection not found")        # 404
except QuotaExceededError:
    print("Weekly quota exceeded")       # 429
except BadRequestError as e:
    print(f"Bad request: {e.message}")   # 400 — e.message is the clean error string
except ServiceUnavailableError:
    print("Upstream service unavailable") # 502
except NetworkError:
    print("Network error (timeout, DNS, etc.)")

License

Elastic-2.0

Metadata

Release files for rustyrag 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rustyrag 0.2.0
File Size Uploaded Provenance Actions
rustyrag-0.2.0.tar.gz 20.1 kB With provenance Details for rustyrag-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rustyrag 0.2.0
File Interpreter ABI Platform Actions
rustyrag-0.2.0-py3-none-any.whl Python 3 none any Details for rustyrag-0.2.0-py3-none-any.whl

Total release size: 38.4 kB

Release files / rustyrag-0.2.0.tar.gz

Download URL rustyrag-0.2.0.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3103960575eb61df71a30e4b8aebcb46402a818623f2a7eaa47ac76906809305
BLAKE2b-256 checksum
How to use checksums
2f82865f024f66245f27431f86287ff711b9ea80cf1e89d22961ea02dbddcae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

Release files / rustyrag-0.2.0-py3-none-any.whl

Download URL rustyrag-0.2.0-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2fd28c0445439215748f12da7451d661bc14481a37f2e786ac330dc88348d02
BLAKE2b-256 checksum
How to use checksums
a05286419231874333e801e331583e5498eea48c858cab6aa5b8bce1b8a7a9e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

Security for rustyrag 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rustyrag-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page