Skip to main content

Universal RAG framework SDK for Python developers

Project description

RAGKit

Universal RAG (Retrieval-Augmented Generation) framework SDK for Python.

Build AI-powered assistants, document search, and FAQ systems in minutes — without rewriting the pipeline for every project.

CI Coverage PyPI License: MIT Python 3.10+


What is RAGKit?

RAGKit is an open-source Python SDK that gives you a complete Retrieval-Augmented Generation pipeline in a few lines of code.

You plug in your data sources, RAGKit handles the rest: chunking, embedding, vector storage, retrieval, and LLM generation via OpenRouter.

Your Data → RAGKit → Answer

Quick Start

pip install ragkit
rag init

Add your API key to .env:

OPENROUTER_API_KEY=your-key-here

Build your first agent:

from ragkit import Agent, MarkdownSource

agent = Agent()
agent.use(MarkdownSource("./docs"))
agent.index()

print(agent.ask("How does authentication work?"))

That's it. No vector database setup. No embedding model download configuration. No prompt engineering.


Features

  • 6 built-in sources — Markdown, TXT, JSON, CSV, REST API, Directory
  • Automatic pipeline — load → clean → chunk → embed → index
  • Semantic search — Chroma or Qdrant vector store
  • 100+ LLMs — via OpenRouter (GPT-4o, Claude, Gemini, Llama…)
  • Streaming — async token-by-token output
  • Cache — embeddings and query results cached on disk
  • Hooks — intercept before/after generate and response
  • Plugin systempip install ragkit-pdf to add PDF support
  • CLIrag init, rag index, rag ask, rag dev, rag serve

Installation

pip install ragkit

Optional extras:

pip install ragkit[serve]    # HTTP server (FastAPI + uvicorn)
pip install ragkit[qdrant]   # Qdrant vector store

Usage Examples

Multiple sources

from ragkit import Agent, MarkdownSource, CsvSource, RestSource

agent = Agent()
agent.use(MarkdownSource("./docs"))
agent.use(CsvSource("./faq.csv", content_column="answer"))
agent.use(RestSource("https://api.example.com/kb", content_key="body"))

agent.index()
print(agent.ask("What is the return policy?"))

Streaming

import asyncio

async def main():
    agent = Agent()
    agent.use(MarkdownSource("./docs"))
    agent.index()

    async for token in agent.stream("Summarize the onboarding guide"):
        print(token, end="", flush=True)

asyncio.run(main())

Custom model

from ragkit import Agent
from ragkit.models import OpenRouterProvider

agent = Agent()
agent.set_model(OpenRouterProvider(
    model="anthropic/claude-sonnet-4-5",
    temperature=0.3,
))

Hooks

@agent.on("before_generate")
def log_prompt(prompt: str) -> None:
    print(f"Sending {len(prompt)} chars to LLM")

@agent.on("after_response")
def save_answer(response: str) -> None:
    with open("answers.log", "a") as f:
        f.write(response + "\n")

Extend with a custom source

from ragkit.core.base import SourceAdapter, Document

class NotionSource(SourceAdapter):
    def load(self) -> list[Document]:
        # fetch from Notion API
        ...

agent.use(NotionSource())

CLI

rag init                        # Initialize a new project (rag.yaml + .env)
rag index                       # Index all configured sources
rag sync                        # Sync sources and re-index
rag ask "What is X?"            # One-shot question
rag dev                         # Interactive REPL
rag serve --host 0.0.0.0        # HTTP API on /ask

Documentation

Full documentation: hustlerlabs.github.io/ragkit


Roadmap

Version Features
V0.1 Core pipeline, 6 sources, Chroma, OpenRouter, CLI, cache, hooks, plugins
V0.2 Hybrid search (BM25 + vector), streaming CLI, plugin PDF
V0.3 PostgreSQL, MongoDB sources
V0.5 Observability (cost tracking, latency dashboard)
V1.0 Stable API, full docs site

Contributing

Contributions are welcome. See CONTRIBUTING for guidelines.

git clone https://github.com/HustlerLabs/ragkit
cd ragkit
pip install -e ".[dev]"
pytest tests/

License

MIT — see LICENSE.

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

ragkit_sdk-0.1.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

ragkit_sdk-0.1.0-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file ragkit_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: ragkit_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for ragkit_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7b538cd157b6414ac20b4787100d08be1b714b386844b9e4052b71cf2bfe1e12
MD5 79ada2a86f91248cfa385c18a75a8939
BLAKE2b-256 2d65acae8f9b02e72faabe1cc3209e8209ac739b6be325065942b1a6233c6f71

See more details on using hashes here.

File details

Details for the file ragkit_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ragkit_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for ragkit_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d152a4deec84e6f5bb8b1dc79bdab29fc2ce0e1e420a6de0ccdda0ea5dcacb2e
MD5 0f27cafd863025f68dda6b91bb81dfb0
BLAKE2b-256 560a653c34b67710f5f0f67c6f4de20a0f73cbe8ff87cf2aa63652e960f352d0

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