Welcome to the RAGForge API documentation. This guide provides instructions on how to programmatically interact with the RAGForge platform to manage projects, pipelines, and perform RAG (Retrieval-Augmented Generation) queries.
All API requests should be made to:
http://localhost:3000/api/trpc (Local Development)
https://your-domain.com/api/trpc (Production)
RAGForge supports two methods of authentication:
For browser-based interactions, RAGForge uses Clerk for identity management. Session cookies (app_session_id) are automatically managed when using the web dashboard.
For server-to-server or script-based access, you can generate API keys in the Settings > API Keys section of the dashboard.
How to use API Keys:
Include your API key in the X-API-Key header of every request.
curl -H "X-API-Key: rg_your_api_key_here" ...RAGForge uses the tRPC protocol. All requests are GET (for queries) or POST (for mutations).
- Payload Structure: Requests sent to
/api/trpc/[router].[method]expect a JSON object in theinputquery parameter (for GET) or request body (for POST). - Batching: tRPC supports batching multiple calls into a single HTTP request.
Manage top-level organizational units.
projects.list(Query): List all projects owned by the user.projects.create(Mutation):{ name: string, description?: string }projects.delete(Mutation):{ projectId: number }
Manage RAG pipelines within a project.
pipelines.list(Query):{ projectId: number }pipelines.get(Query):{ pipelineId: number }pipelines.status(Query):{ pipelineId: number }- Returns ingestion stats and usage.
Manage configuration versions for a pipeline.
versions.list(Query):{ pipelineId: number }versions.updateConfig(Mutation):{ "versionId": number, "chunkSize": number, "chunkOverlap": number, "enableGraphRAG": boolean }
Upload and manage knowledge sources.
documents.list(Query):{ versionId: number }documents.getPresignedUrl(Mutation):{ versionId: number, filename: string, fileType: string }- Returns an S3 pre-signed URL for upload.documents.upload(Mutation): Register a completed upload.documents.confirmOCR(Mutation):{ documentId: number }- Manually trigger OCR for low-content PDFs.
Perform raw semantic search across documents.
search.query(Query):{ "versionId": number, "query": string, "limit": number }
Perform RAG-powered conversations.
chat.query(Mutation):Response:{ "versionId": number, "message": string, "systemPrompt": string (optional) }{ "response": "The answer generated by LLM...", "sources": [ { "documentName": "doc1.pdf", "pageNo": 5, "text": "..." } ], "tokensUsed": 1542 }
import requests
import json
BASE_URL = "http://localhost:3000/api/trpc"
API_KEY = "rg_your_actual_key"
def rag_query(version_id, message):
url = f"{BASE_URL}/chat.query"
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json"
}
payload = {
"json": {
"versionId": version_id,
"message": message
}
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
return response.json()
# Example Usage
result = rag_query(1, "What is the summary of the Urdu document?")
print(result['result']['data']['response'])import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from './server/routers';
const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://localhost:3000/api/trpc',
headers() {
return {
'X-API-Key': 'rg_your_actual_key',
};
},
}),
],
});
const response = await client.chat.query.mutate({
versionId: 1,
message: "Tell me about the Quranic evidence.",
});