Production-oriented Python framework for building RAG services on top of FastAPI.
Project description
SyRAG
SyRAG is a production-oriented Python framework for building Retrieval-Augmented Generation services with a small, typed API on top of FastAPI.
Supported Python versions: 3.12 and 3.13.
It currently ships:
SyRAGapplication wrapper pluscreate_app()@app.ingest(...)and@app.query(...)decorators- typed request and response schemas
- in-memory providers for development and tests
- Chroma and FAISS vector stores behind optional extras
- SQLite vector store in core
- OpenAI and Google model providers behind optional extras
- request context, auth hooks, tenant scoping, rate limiting, and safety guards
- OpenAPI docs, structured logging, and OpenTelemetry-compatible tracing
- a testing toolkit with fake providers and ASGI client helpers
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.1.0",
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 /ingestPOST /queryGET /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:
ChunkerEmbedderVectorStoreRetrievalStrategyPromptAssemblerGenerationPolicyLLMRequestContextHookAuthHookRateLimiterSafetyGuard
First-Party Providers
Core:
InMemoryEmbedderInMemoryVectorStoreInMemoryLLMPassThroughChunkerSQLiteVectorStore
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:
GoogleEmbedderGoogleLLM
Optional openai extra:
OpenAIEmbedderOpenAILLM
Observability And Operations
SyRAG includes:
- structured error responses with stage information
- request-scoped
RequestContextwith request IDs and tenant IDs StructuredLoggingandJSONLogFormatterOpenTelemetryTracingbuilt 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, andFakeLLM
Docs
- Docs index
- Overview
- Architecture
- Component contracts
- Public API
- Compatibility matrix
- Cookbook
- Provider examples
- 0.2.0 roadmap
- Releasing
- MVP status
Examples
Cookbook
- Qdrant vector store pipeline
- LangChain + Qdrant RAG
- LangChain agent with SyRAG tool
- LangGraph + SyRAG RAG workflow
- LlamaIndex + Qdrant RAG
Full example scripts live in examples/integrations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syrag-0.2.0.tar.gz.
File metadata
- Download URL: syrag-0.2.0.tar.gz
- Upload date:
- Size: 244.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59238ad92bf93d4837f19eb38d8ba9172017e8b03f1fe0b19238076da00dc3ad
|
|
| MD5 |
ba04dae4f895f8cd69577082f672b313
|
|
| BLAKE2b-256 |
1b6c6190c537b16c5ce71f42797cf504c1bc072e9f22082629279b151c2ef633
|
Provenance
The following attestation bundles were made for syrag-0.2.0.tar.gz:
Publisher:
publish.yml on a-marzoug/syrag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syrag-0.2.0.tar.gz -
Subject digest:
59238ad92bf93d4837f19eb38d8ba9172017e8b03f1fe0b19238076da00dc3ad - Sigstore transparency entry: 1519521383
- Sigstore integration time:
-
Permalink:
a-marzoug/syrag@b135311174b4c87c539f1b788be02aae11be5126 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/a-marzoug
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b135311174b4c87c539f1b788be02aae11be5126 -
Trigger Event:
push
-
Statement type:
File details
Details for the file syrag-0.2.0-py3-none-any.whl.
File metadata
- Download URL: syrag-0.2.0-py3-none-any.whl
- Upload date:
- Size: 57.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2303e07545d46d5fe53eab7ae549dd115887793175c4c267042893eadd188232
|
|
| MD5 |
c8604c96035ae9547808cdedcffae474
|
|
| BLAKE2b-256 |
2400c067cb30f74c945b1cde493f4cc8bc8779df6155e5cfc36363f68fcbd56e
|
Provenance
The following attestation bundles were made for syrag-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on a-marzoug/syrag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syrag-0.2.0-py3-none-any.whl -
Subject digest:
2303e07545d46d5fe53eab7ae549dd115887793175c4c267042893eadd188232 - Sigstore transparency entry: 1519521482
- Sigstore integration time:
-
Permalink:
a-marzoug/syrag@b135311174b4c87c539f1b788be02aae11be5126 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/a-marzoug
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b135311174b4c87c539f1b788be02aae11be5126 -
Trigger Event:
push
-
Statement type: