Skip to main content

SyRAG logo

SyRAG

Build typed, production-oriented RAG services with a FastAPI-style developer experience.

PyPI Python versions CI Docs License

SyRAG is a Python framework for building Retrieval-Augmented Generation services with explicit pipeline contracts, typed request/response models, and production-facing defaults on top of FastAPI.

It is designed for teams that want RAG APIs with clean provider boundaries, OpenAPI docs, request context, observability, guardrails, and testable local development without committing their whole application to a single orchestration framework.

Highlights

  • FastAPI-style @app.ingest(...) and @app.query(...) route decorators.
  • Typed schemas for ingest, retrieval, generation, citations, usage, and errors.
  • Protocol-first extension points for chunkers, embedders, vector stores, retrieval strategies, prompt assembly, generation policies, LLMs, hooks, rate limiters, and safety guards.
  • Optional integrations for OpenAI, Google, Chroma, FAISS, LangChain, and LlamaIndex.
  • Development/test providers and testing helpers for reliable local and CI workflows.
  • OpenAPI output, structured logging, and OpenTelemetry-compatible tracing.

Supported Python versions: 3.12+.

Installation

Core package:

pip install syrag

Optional integrations:

pip install "syrag[chroma]"
pip install "syrag[faiss]"
pip install "syrag[google]"
pip install "syrag[langchain]"
pip install "syrag[llamaindex]"
pip install "syrag[openai]"
pip install "syrag[testing]"
pip install "syrag[server]"
pip install "syrag[all]"

Quick Start

Install the runtime integrations used in this example:

pip install "syrag[chroma,openai,server]"

Set OPENAI_API_KEY in your environment before starting the app.

Create main.py:

import os
from pathlib import Path

from syrag import (
    SyRAG,
    ChromaVectorStore,
    IngestRequest,
    OpenAIEmbedder,
    OpenAILLM,
    QueryRequest,
    Settings,
)

app = SyRAG(
    title="Support Bot",
    version="0.2.1",
    description="Internal support assistant",
    settings=Settings(),
)

SUPPORT_COLLECTION = "support"

embedder = OpenAIEmbedder(
    api_key=os.environ["OPENAI_API_KEY"],
    model="text-embedding-3-small",
)
vector_store = ChromaVectorStore(
    path=Path(".syrag/chroma"),
    collection_name="support_docs",
)
llm = OpenAILLM(api_key=os.environ["OPENAI_API_KEY"], model="gpt-4.1-mini")


@app.ingest("/ingest", embedder=embedder, vector_store=vector_store)
async def ingest(request: IngestRequest) -> IngestRequest:
    """Normalize incoming documents before they enter the ingest pipeline."""
    return request.model_copy(
        update={
            "collection": request.collection or SUPPORT_COLLECTION,
            "metadata": {"source": "api", **request.metadata},
        }
    )


@app.query("/query", embedder=embedder, vector_store=vector_store, llm=llm)
async def query(request: QueryRequest) -> QueryRequest:
    """Apply route-level retrieval defaults before generation."""
    return request.model_copy(
        update={
            "collection": request.collection or SUPPORT_COLLECTION,
            "top_k": min(request.top_k, 5),
        }
    )

Serve the app with any ASGI server. With the server extra installed:

uvicorn main:app.api --reload

The framework exposes:

  • POST /ingest
  • POST /query
  • GET /health
  • OpenAPI docs at /docs

Ingest a document:

curl -X POST http://127.0.0.1:8000/ingest \
  -H "content-type: application/json" \
  -d '{"documents":["SyRAG builds typed RAG services."],"collection":"demo"}'

Query it:

curl -X POST http://127.0.0.1:8000/query \
  -H "content-type: application/json" \
  -d '{"query":"What does SyRAG build?","collection":"demo","top_k":1}'

Extension Points

SyRAG keeps the pipeline explicit. You can swap or extend:

  • Chunker
  • Embedder
  • VectorStore
  • RetrievalStrategy
  • PromptAssembler
  • GenerationPolicy
  • LLM
  • RequestContextHook
  • AuthHook
  • RateLimiter
  • SafetyGuard

First-Party Providers

Core:

  • InMemoryEmbedder
  • InMemoryVectorStore
  • InMemoryLLM
  • PassThroughChunker
  • SQLiteVectorStore

InMemoryEmbedder, InMemoryVectorStore, and InMemoryLLM are development/test utilities. They are not intended as production embedding, retrieval, or generation backends.

Optional chroma extra:

  • ChromaVectorStore

Optional faiss extra:

  • FAISSVectorStore

Optional google extra:

  • GoogleEmbedder
  • GoogleLLM

Optional openai extra:

  • OpenAIEmbedder
  • OpenAILLM

Observability And Operations

SyRAG includes:

  • structured error responses with stage information
  • request-scoped RequestContext with request IDs and tenant IDs
  • StructuredLogging and JSONLogFormatter
  • OpenTelemetryTracing built on the OpenTelemetry API package
  • request throttling via InMemoryRateLimiter
  • payload validation via DefaultSafetyGuard

Testing

Install the testing extra to use:

  • create_test_app(...)
  • create_test_client(...)
  • seed_documents(...)
  • fake providers such as FakeEmbedder, FakeVectorStore, and FakeLLM

Docs

Build the docs locally with MkDocs Material:

uv run --group docs mkdocs serve

Examples

Cookbook

Full example scripts live in examples/integrations.

Community

Metadata

Release files for syrag 0.2.1

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

Source distribution (sdist)

Source distribution for syrag 0.2.1
File Size Uploaded Provenance Actions
syrag-0.2.1.tar.gz 330.2 kB With provenance Details for syrag-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 387.9 kB

Release files / syrag-0.2.1.tar.gz

Download URL syrag-0.2.1.tar.gz
Size 330.2 kB
Tags Source
SHA-256 checksum
How to use checksums
629b42bc576aef2efef51c386746b6ab325a26f0aaf1b0119273982197571b8c
BLAKE2b-256 checksum
How to use checksums
9990ee6d0d209f2a46b0d4d0849d415ca1d5f957f2844bbb5f0bf5cf110f1e42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 May 17, 2026.

Transparency log

Release files / syrag-0.2.1-py3-none-any.whl

Download URL syrag-0.2.1-py3-none-any.whl
Size 57.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ecc8d4c3d517e8c83a77ba37b2afa66452e570573349911bf4d2040fdb60122
BLAKE2b-256 checksum
How to use checksums
a81cf05054d478ba2dd43580abb0c4b6210a48adf2af7bb34621383f39ca9f8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 May 17, 2026.

Transparency log

Security for syrag 0.2.1

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 syrag-0.2.1.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 May 17, 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.

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