A lightweight, client-side RAG (Retrieval-Augmented Generation) chat interface that works with any RAG-compatible API using just a full API URL and a Bearer token.
✅ No backend needed
✅ Chat history saved locally in your browser
✅ Zero dependencies — pure HTML/JS
✅ Privacy-first — your data never leaves your machine
✅ Supports CORS proxy for cross-origin APIs
Perfect for testing, demoing, or embedding a RAG chat into your workflow — especially when your API expects a simple {"query": "..."} payload and returns structured answers.
- 🔒 Secure: API token never leaves your browser
- 💾 Persistent local chat history (via
localStorage) - 📜 Auto-trims long conversations to stay within token limits (~20k tokens)
- 📂 Sidebar to browse and switch between past chats
- 🌐 Works with any RAG API that:
- Accepts
POSTwith{"query": "..."}in JSON body - Uses Bearer token authentication
- Returns answer in common fields like
answer,output,response, etc.
- Accepts
- 🛡️ Built-in CORS proxy support (optional)
This app works with any RAG API that follows standard patterns. Examples:
- API URL:
https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/autorag/rags/<RAG_ID>/ai-search - Token: Your Cloudflare API Token with "Account AI Read" permission
- API URL:
https://your-rag-api.example.com/query
(must accept{"query": "..."}and return JSON withanswerfield) - Token: Any Bearer token your backend expects (e.g., from Auth0, Firebase, or a static key)
💡 Tip: If you're building your own RAG API, ensure it responds with a JSON object like:
{ "answer": "The capital of France is Paris.", "sources": ["https://example.com/doc1", "https://example.com/doc2"] }
- Download
index.html - Open it in Chrome, Edge, or Firefox
- Enter:
- Full API URL (e.g.,
https://api.yourservice.com/rag) - Bearer Token (your secret key)
- Full API URL (e.g.,
- Click Save → Start chatting!
⚠️ Note: Some browsers blocklocalStorageonfile://URLs. If chat history doesn’t persist:
- Serve via a local server:
npx serve # or python3 -m http.server 8000
- Deploy
index.htmlto GitHub Pages, Netlify, Vercel, etc. - Works out of the box!
- Visit https://rag-chat-dk0.pages.dev/
- Use.
| Element | Function |
|---|---|
| API URL field | Paste your full RAG endpoint |
| Token field | Enter your Bearer token (hidden) |
| Save button | Stores API URL in browser (token is never saved) |
| New Chat | Starts fresh conversation |
| ☰ (Sidebar) | View & switch between past chats |
| Send / Enter | Submit message (use Shift+Enter for new line) |
🔐 Security Note: Your token is never stored—only the API URL is saved in
localStoragefor convenience.
Your backend must:
- Accept
POSTrequests with:{ "query": "User's full contextual question" } - Use Bearer auth:
Authorization: Bearer <your-token> - Return JSON with at least one of these fields:
answeroutputresponsetext- Or a string at the root level
Optional: Include sources as an array of URLs for citation.
✅ Example Response:
{
"answer": "Paris is the capital of France.",
"sources": ["https://en.wikipedia.org/wiki/Paris"]
}If your API blocks cross-origin requests, the app uses a public CORS proxy by default:
https://cors.jammesop007.workers.dev/?u=<YOUR_ENCODED_URL>
⚠️ For production: Replace this with your own proxy or ensure your API allowsOrigin: null(forfile://) or your domain.
To use your own proxy, edit this line in the code:
const CORS_PROXY = "https://your-proxy.com/?u=";Want to test without a real API? Use a mock service:
- Create a mock endpoint that returns:
{ "answer": "This is a test response!", "sources": ["https://example.com"] } - Use the mock URL as your API URL
- Put any string as the token (it won’t be validated)
MIT — feel free to use, modify, and embed in your projects!
- Cloudflare AI Gateway demos
- LangChain conversational RAG patterns
- Privacy-focused AI interfaces
✨ Built for developers, analysts, and AI tinkerers who want full control — without backend hassle.