Official Python SDK for the RAGify RAG-as-a-Service API
Project description
ez-ragify Python SDK
Official Python SDK for the RAGify RAG-as-a-Service API. Build retrieval-augmented generation pipelines with a single function call.
Installation
pip install ez-ragify
Or install from source:
cd sdks/python
pip install -e ".[dev]"
Quick Start
API Key Authentication (project-scoped)
from ez_ragify import EzRagify
client = EzRagify(api_key="rag_abc123...")
# Ask a question against your project
response = client.query("What is the refund policy?", project_id=1)
print(response.answer)
for citation in response.citations:
print(f" - {citation.filename} p.{citation.page_number}: {citation.snippet}")
Bearer Token Authentication (user-scoped)
client = EzRagify(bearer_token="eyJhbGci...")
# Manage projects
projects = client.list_projects()
Streaming
Stream tokens in real-time for a responsive UX:
client = EzRagify(api_key="rag_abc123...")
for chunk in client.query_stream("Summarize the document", project_id=1):
if chunk.type == "chunk":
print(chunk.content, end="", flush=True)
elif chunk.type == "citations":
print("\n\nSources:")
for c in chunk.citations:
print(f" - {c.filename}: {c.snippet[:80]}")
Async Support
import asyncio
from ez_ragify import AsyncEzRagify
async def main():
async with AsyncEzRagify(api_key="rag_abc123...") as client:
response = await client.query("What are the tax deadlines?", project_id=1)
print(response.answer)
# Streaming
async for chunk in client.query_stream("Summarize", project_id=1):
if chunk.type == "chunk":
print(chunk.content, end="")
asyncio.run(main())
API Reference
Client Initialization
EzRagify(
api_key="...", # Project-scoped API key (X-API-Key header)
bearer_token="...", # User-scoped JWT (Authorization: Bearer header)
base_url="http://...", # Default: http://localhost:8000/api/v1
timeout=30.0, # Default request timeout in seconds
)
RAG Queries
| Method | Description |
|---|---|
client.query(query, project_id, top_k=4) |
Full response (collects stream) |
client.query_stream(query, project_id, top_k=4) |
Generator of StreamChunk |
Projects
| Method | Description |
|---|---|
client.create_project(ProjectCreate(...)) |
Create project |
client.list_projects(skip=0, limit=100) |
List user's projects |
client.get_project(project_id) |
Get single project |
client.update_project(project_id, ProjectUpdate(...)) |
Update config |
client.delete_project(project_id) |
Delete project |
client.list_models() |
Available LLM models |
client.get_api_key(project_id) |
Get API key prefix |
client.regenerate_api_key(project_id) |
Regenerate API key |
Documents
| Method | Description |
|---|---|
client.upload_document(project_id, file) |
Upload PDF/DOCX/TXT/MD |
client.list_documents(project_id) |
List project documents |
client.delete_document(document_id) |
Delete a document |
file can be a file path string or a file-like object:
# From path
doc = client.upload_document(1, "/path/to/report.pdf")
# From file object
with open("report.pdf", "rb") as f:
doc = client.upload_document(1, f, filename="report.pdf")
Usage & Analytics
| Method | Description |
|---|---|
client.get_usage() |
Aggregate usage stats |
client.get_project_logs(project_id, limit=50, offset=0) |
Per-project query logs |
User Profile
| Method | Description |
|---|---|
client.get_profile() |
Get current user profile |
client.update_profile(display_name="...") |
Update display name |
client.delete_account() |
Delete account and all data |
Error Handling
from ez_ragify import EzRagify, EzRagifyError, AuthenticationError, RateLimitError, NotFoundError
client = EzRagify(api_key="rag_...")
try:
response = client.query("Hello", project_id=999)
except NotFoundError:
print("Project not found")
except RateLimitError as e:
print(f"Rate limited — retry after {e.retry_after}s")
except AuthenticationError:
print("Invalid API key")
except EzRagifyError as e:
print(f"API error {e.status_code}: {e.message}")
Types
All response objects are Pydantic models with full type hints:
Project,ProjectCreate,ProjectUpdateDocumentQueryResponse,StreamChunk,CitationUsageStats,ProjectLog,ProjectLogsUserProfileModelAPIKey,APIKeyWithPlaintext
License
MIT
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 ez_ragify-0.1.0.tar.gz.
File metadata
- Download URL: ez_ragify-0.1.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ca2e1ebb5704c75cdcac62670d06187019dd173630d84edff74815f8954bdb6
|
|
| MD5 |
a314a7b13bdce49b66b03626f300e63f
|
|
| BLAKE2b-256 |
6cf616850d0283571ea096818a4a702cf0c9cc6843a9ff62127c70af75273e5a
|
File details
Details for the file ez_ragify-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ez_ragify-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8c242ce55d8c3088ee3fa05761941f074b5b34101dd59368295f472c23576a4
|
|
| MD5 |
3cb9995d9638aee3ac62b570bc4124db
|
|
| BLAKE2b-256 |
649a3565afa94af479ff328385c4321d6806c24a3a2ea9942984d4446321d338
|