Chat With Any Approved Model
Use Ollama, OpenAI, OpenRouter, Claude, Grok, Sarvam AI, or private OpenAI-compatible gateways from one chat workspace.
Overview
Use Ollama, OpenAI, OpenRouter, Claude, Grok, Sarvam AI, or private OpenAI-compatible gateways from one chat workspace.
Upload, index, search, reindex, download, and delete documents with local or OpenAI embeddings.
Run local JSON vectors by default, connect ChromaDB for self-hosted vector search, or use Pinecone for managed vector search.
Let users create personal API keys and call admin-approved models through OpenAI-compatible API endpoints.
Use Better Auth with users, admins, roles, organizations, teams, invitations, SSO, OAuth/OIDC, and SCIM.
Track audit events, GDPR requests, ISO 27001/SOC 2 controls, retention notes, and CSV exports.
Deploy with Docker, local files, SQLite, PostgreSQL, MySQL, and ChromaDB profiles for enterprise environments.
Get Started
Batuk runs as a Next.js app. The fastest local path uses local JSON product data, SQLite auth, and either Ollama or a hosted provider configured from Settings.
npm install
npm run dev
# Optional local model runtime
ollama pull llama3.1
ollama serveCompare
Review production-grade Batuk comparisons for RAG privacy, API gateway controls, admin management, token analytics, audit evidence, deployment, and provider coverage.
All comparisonsBatuk vs
Compare Batuk and Open WebUI for enterprise AI chat, RAG privacy, model routing, API keys, audit, admin controls, MCP, and self-hosted deployment.
Read comparisonBatuk vs
Compare Batuk and AnythingLLM across local AI, document chat, agents, vector databases, API access, enterprise controls, RAG privacy, and model gateway use cases.
Read comparisonBatuk vs
Compare Batuk and LibreChat for multi-model chat, agents, RAG, MCP, API access, enterprise admin, workspace privacy, compliance, and deployment.
Read comparisonBatuk vs
Compare Batuk and Langdock for enterprise AI adoption, model choice, RAG, agents, workflows, APIs, deployment, compliance, and data control.
Read comparisonConcepts
The model backend selected for a chat request: Ollama, OpenAI, OpenRouter, Claude, Grok, Sarvam AI, or custom compatible.
A top-bar mode that retrieves indexed document chunks from the signed-in user's personal scope or the selected shared workspace.
An admin-managed public API model ID that maps external clients to an approved provider, model, and base URL.
A user-owned Batuk key for programmatic access. The raw secret is shown once and only a hash is persisted.
A reusable instruction package with description, examples, resources, and enabled state.
A saved chain of agents where each agent receives prior output and passes the next handoff forward.
An enterprise boundary for teams, members, roles, branding, admin pages, token usage, and scoped product data.
An admin-created collaboration scope where invited users can access workspace chats and workspace RAG without mixing data into personal context.
A compliance record for access, admin, document, privacy, and product actions.
Architecture
app/
api/
ai-lab/
components/
chat/
docs/
enterprise/
audit/
hooks/
lib/
auth*
rag*
product-data-store.js
database/
scripts/Configure
For local evaluation, most settings can be supplied through the UI. For enterprise deployment, use `.env.enterprise.example` as the canonical starting point. Keep one product data provider and one Better Auth database provider active at a time.
| Variable | Values | Purpose |
|---|---|---|
| BATUK_DATA_STORE_PROVIDER | json | sqlite | postgresql | mysql | Selects where Batuk product data is stored. |
| BATUK_DATA_DIR | Path | Root directory for JSON stores and local runtime data. |
| BATUK_DOCUMENT_FILE_STORAGE_DIR | Path | Stores original uploaded RAG documents. |
| BATUK_BRANDING_FILE_STORAGE_DIR | Path | Stores organization logo uploads. |
| BATUK_VECTOR_STORE_PROVIDER | json | chroma | pinecone | Selects vector database mode for RAG. |
| BETTER_AUTH_DATABASE_PROVIDER | sqlite | mysql | postgresql | mssql | mongodb | Selects the Better Auth identity database adapter. |
| BETTER_AUTH_URL | URL | Public origin for auth callbacks and cookie handling. |
| BETTER_AUTH_SECRET | Secret | Session and auth signing secret. Required for production. |
| BETTER_AUTH_PROVIDER_MODE | oauth | legacy-oidc | Controls OAuth/OIDC provider mode. |
| BATUK_AUDIT_ENABLED | true | false | Controls local audit evidence capture. |
Configure
Batuk keeps the chat experience stable while providers change underneath. A team can run local models, hosted APIs, private gateways, or a mix of all three.
| Provider | Role | Configuration | Notes |
|---|---|---|---|
| Ollama | Local/private inference | Base URL and installed model ID | Best for offline and private model runs. |
| OpenAI | Chat, embeddings, web search, realtime voice | Provider key and selected model | Required for OpenAI embeddings and Realtime voice. |
| OpenRouter | Routed model catalog | Provider key and model ID | Useful when teams want access to many hosted models. |
| Claude | Anthropic Messages API | Provider key and Claude model | Supports hosted Anthropic models. |
| Grok | xAI models | Provider key and model ID | Supports xAI chat workflows. |
| Sarvam AI | Indian-language optimized models | Provider key and Sarvam model | Useful for multilingual India-focused workflows. |
| Custom compatible | LM Studio, vLLM, llama.cpp, LiteLLM, gateways | Base URL, model ID, optional key | Use for private model routers or local OpenAI-compatible servers. |
Configure
RAG starts in the Documents workspace. Batuk stores original uploads locally, extracts text, chunks content, computes embeddings, writes vectors, and retrieves matching chunks when Document Chat is enabled.
# Local JSON vectors
BATUK_VECTOR_STORE_PROVIDER=json
BATUK_LOCAL_VECTOR_DIR=/app/data/vectors
# ChromaDB
BATUK_VECTOR_STORE_PROVIDER=chroma
CHROMA_URL=http://chroma:8000
CHROMA_COLLECTION=sb_chat_documents
# Pinecone
BATUK_VECTOR_STORE_PROVIDER=pinecone
PINECONE_INDEX=sb-chat-documents
PINECONE_NAMESPACE=documentsConfigure
Batuk separates identity storage, product data, source files, branding assets, and vectors. This lets a small local install stay simple while enterprise deployments use durable databases and mounted volumes.
| Layer | Default | Enterprise Options | Stores |
|---|---|---|---|
| Auth DB | SQLite | SQLite, MySQL, PostgreSQL, MS SQL, MongoDB | Better Auth users, sessions, accounts, organizations, teams, OAuth/OIDC, SSO, and SCIM. |
| Product data | Local JSON | SQLite, MySQL, PostgreSQL | Chats, folders, workspaces, documents metadata/chunks, memories, API management records, skills, agents, workflows, branding, token usage, compliance, and audit trails. |
| Documents | Local files | Configurable local/container path | Original uploaded files used for download and reindex operations. |
| Branding | public/branding | Configurable local/container path | Organization logos and whitelabel assets. |
| Vectors | Local JSON | ChromaDB, Pinecone | Document chunk embeddings for RAG retrieval. |
Configure
npm run auth:migrate
# Auth adapters
sqlite
mysql
postgresql
mssql
mongodbConfigure
Batuk can operate like an internal OpenRouter-style gateway. Admins decide which provider/model routes are exposed, while each user creates their own API key for programmatic access.
| Capability | Behavior |
|---|---|
| User API keys | Every signed-in user can create a personal Batuk key, copy the secret once, and revoke it later. |
| Secret storage | Raw API keys are never stored. Batuk stores a SHA-256 hash, a display preview, status, owner metadata, and timestamps. |
| Admin controls | Admins can review all user keys, revoke individual keys, revoke all API access for a user, and manage public model routes. |
| Model routes | Admins map public model IDs to provider, underlying model, base URL, and enabled state. |
| Compatible endpoints | Clients call GET /api/v1/models and POST /api/v1/chat/completions with Authorization: Bearer batuk_... |
| Usage tracking | API requests are recorded with source api, user, API key ID, public model ID, provider, tokens, and timestamps. |
# List admin-enabled models
curl -H "Authorization: Bearer batuk_..." \
http://localhost:3000/api/v1/models
# Create a chat completion
curl -X POST http://localhost:3000/api/v1/chat/completions \
-H "Authorization: Bearer batuk_..." \
-H "Content-Type: application/json" \
-d '{
"model": "batuk/qwen3-8b",
"messages": [
{ "role": "user", "content": "Hello" }
]
}'Use
Assistant responses stream into the chat UI where supported by the provider.
Messages render Markdown and GitHub-flavored tables/lists through react-markdown and remark-gfm.
Temporary conversations are visibly marked and not written to the saved chat history.
Chats can be organized into workspaces and folders, searched, imported, exported, and continued later.
Safer request screening and system behavior can be enabled while raw model mode remains available.
New Chat returns users to the main chat window and opens a fresh conversation from any screen.
Use
Use
Skills are reusable instructions that can travel with future chats. They are useful for house style, code review rules, domain response patterns, compliance checklists, and repeated workflows.
Use
Agent 1 -> Extract facts
Agent 2 -> Reason over constraints
Agent 3 -> Produce final answer
Final output -> Chat windowUse
Batuk creates OpenAI Realtime browser sessions through a server endpoint, streams microphone audio, receives spoken replies, and inserts transcripts into chat.
OpenAI hosted web search can be enabled from the composer when current external context is required. It is optional and provider-specific.
Operate
Operate
Token usage is now an operations dashboard, not just a running total. Chat and API traffic are separated so admins can inspect product adoption, cost drivers, and high-volume integrations.
| Dimension | What it shows |
|---|---|
| Channel | Separates chat requests from API requests. |
| User | Aggregates usage by signed-in user ID or email. |
| Chat | Tracks usage by chat ID for saved conversations and unsaved-chat for unsaved chat traffic. |
| API key | Tracks API usage by key ID so admins can inspect programmatic adoption and revoke risky access. |
| Provider/model | Shows usage by provider and public model ID. |
| Time | Rolls usage up by day, month, and year with numeric totals and lightweight charts. |
recordTokenUsage({
source: "api", // or "chat"
userId,
userEmail,
chatId,
apiKeyId,
apiModel,
provider,
model,
inputTokens,
outputTokens,
totalTokens
})Operate
Operate
The Audit workspace is an evidence and operations surface. It helps teams capture product-level compliance records, but it does not replace legal review, organizational policy, or a formal certification process.
BATUK_AUDIT_ENABLED=true
BATUK_AUDIT_RETENTION_DAYS=365
BATUK_AUDIT_HASH_IDENTIFIERS=true
BATUK_AUDIT_MAX_EVENTS=10000Operate
Product display name, tagline, uploaded logo, logo initials, accent color, and optional organization-name chip.
Footer attribution stays fixed as Batuk, created by Suhas Bhairav.
Branding settings are organization-scoped and stored in JSON or SQL product data.
Uploaded logos are stored in the configured branding file storage directory.
Deploy
Docker Compose keeps optional infrastructure behind profiles. This lets operators test JSON/SQLite locally, then switch to PostgreSQL, MySQL, or ChromaDB by editing the env file and enabling the matching profile.
cp .env.enterprise.example .env.enterprise
# Local JSON + SQLite auth
docker compose up --build
# PostgreSQL
docker compose --profile postgres up --build
# MySQL
docker compose --profile mysql up --build
# PostgreSQL + ChromaDB
docker compose --profile postgres --profile chroma up --buildReference
Set production URL, rotate secrets, configure HTTPS, choose storage, configure backup, validate env, run migrations, and test auth flows.
Back up SQL databases, JSON data, uploaded documents, branding assets, audit records, and vector indexes.
Use least privilege, secret management, network allow lists, role-based admin access, and provider key rotation.
Track app logs, auth failures, audit denials, document indexing failures, token usage, DB health, vector DB health, and storage volume growth.
Support
Local embeddings are 384 dimensions and OpenAI embeddings are 1536 dimensions. Batuk creates dimension-specific sibling indexes when an existing Pinecone index uses the wrong dimension.
Confirm the original file still exists in BATUK_DOCUMENT_FILE_STORAGE_DIR or the mounted Docker data volume.
Confirm upload responses are valid JSON and that BATUK_BRANDING_FILE_STORAGE_DIR is writable by the app container.
Confirm BETTER_AUTH_URL, callback URLs, trusted client JSON, issuer metadata, and public origin match the deployed host.
Confirm the chroma profile is running and CHROMA_URL points to the reachable service URL from the Batuk container.
The entrypoint retries migrations. Tune BATUK_STARTUP_RETRY_ATTEMPTS and BATUK_STARTUP_RETRY_SECONDS for slower enterprise databases.
FAQ
Batuk is an open-source Sovereign AI chat workspace for teams. It lets users chat with local, hosted, and private model providers while adding RAG, agents, enterprise auth, audit, and deployment controls.
Yes. Batuk is an Open WebUI-style alternative built with Next.js and JavaScript, focused on model choice, readable architecture, RAG, enterprise identity, local-first storage, and self-hosted deployment.
No. Batuk supports Ollama and custom OpenAI-compatible endpoints. OpenAI is optional for OpenAI chat models, hosted web search, OpenAI embeddings, and Realtime voice.
Yes, for local models, local files, local JSON or SQL storage, and ChromaDB. Hosted model APIs and Pinecone require a network path unless the enterprise provides private connectivity.
Original uploaded documents are stored in the configured document file storage directory. Personal document metadata, chunks, and vectors are scoped to the signed-in user. Shared workspace documents use a separate workspace scope.
Yes. Users can generate personal Batuk API keys and call admin-enabled models through OpenAI-compatible endpoints for model listing and chat completions.
Raw API keys are not stored. Batuk stores a SHA-256 hash, a short preview, status, owner metadata, and timestamps. The full key is shown once at creation.
Yes. Admins can revoke individual API keys or revoke all active API access for a selected user.
Yes. Batuk uses Better Auth Admin and Organization features for users, roles, organizations, teams, members, invitations, and first-owner bootstrap.
No. Non-admin users can use their own API access, personal chat, documents, and shared workspaces they belong to, but they do not see Workspace Management, Enterprise Management, or Audit and Compliance menu entries.
No product can grant certification alone. Batuk provides product-level evidence workflows, audit trails, GDPR request operations, and control mappings. Formal certification requires organizational controls and auditor review.
Continue into the Batuk guide hub for deeper pages on Advanced RAG, Graph RAG, Open WebUI comparisons, enterprise auth, API access, audit, deployment, vector storage, Skills, agents, MCP direction, and why Batuk is becoming a world-class sovereign AI workspace.
Open Batuk guide hubBatuk is a strong alternative to Open WebUI, LibreChat, AnythingLLM, and Langdock when teams want a self-hosted sovereign AI workspace with chat, RAG, APIs, governance, and extensible integrations.
Batuk is a top enterprise alternative to Open WebUI, LibreChat, and AnythingLLM because it pairs self-hosted AI chat with RAG governance, model control, API access, usage analytics, and integration-ready architecture.
Batuk is one of the best self-hosted AI platforms for teams that want ChatGPT-style UX, private RAG, model choice, admin control, API access, and extensible MCP workflows in one sovereign workspace.
Why Batuk is a stronger sovereign AI chat workspace for one connector context can be chosen or cleared for chat.
Next step
Use the AI Lab page for product context, or open the repository when you are ready to deploy, customize, or extend Batuk.