Skip to main content

Python SDK for RustyRAG — fast, minimal RAG-as-a-Service client

Project description

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

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

rustyrag-0.2.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

rustyrag-0.2.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file rustyrag-0.2.0.tar.gz.

File metadata

  • Download URL: rustyrag-0.2.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rustyrag-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3103960575eb61df71a30e4b8aebcb46402a818623f2a7eaa47ac76906809305
MD5 290be2a81b71e8e1f3c6fc71500a95b1
BLAKE2b-256 2f82865f024f66245f27431f86287ff711b9ea80cf1e89d22961ea02dbddcae3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustyrag-0.2.0.tar.gz:

Publisher: publish.yml on RustyRAG/RustyRAG-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustyrag-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rustyrag-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rustyrag-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2fd28c0445439215748f12da7451d661bc14481a37f2e786ac330dc88348d02
MD5 d611fb9ce92222b161df33569367e62b
BLAKE2b-256 a05286419231874333e801e331583e5498eea48c858cab6aa5b8bce1b8a7a9e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustyrag-0.2.0-py3-none-any.whl:

Publisher: publish.yml on RustyRAG/RustyRAG-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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