anthropic, openai-compatible (or openai), ollama, or ollama-cloud.
Auto-detected when unset: an AI_API_KEY or AI_BASE_URL implies
openai-compatible, otherwise Anthropic.
AI Chat
OwnDocs ships an AI chat widget that answers questions about your documentation and cites the pages it uses. The widget stays hidden until you configure a provider, so there is nothing to turn off when you do not want it.
How it works
The widget is a fixed button in the bottom-right corner. It sends the reader's
question to /api/ai/chat, which retrieves the most relevant pages from the
search index, builds a context window, and streams an answer with source
citations. Chat threads are stored locally in the reader's browser.
Prerequisites
- A provider: Anthropic, an OpenAI-compatible endpoint (OpenAI, OpenRouter, Moonshot Kimi, Z.ai GLM, DeepSeek, Groq, Mistral, xAI, and more), or Ollama (local or cloud).
- The environment variables for that provider, set before building.
Enable with Anthropic
Anthropic is the default when no AI_PROVIDER is set.
ANTHROPIC_API_KEY="your-anthropic-key"
ANTHROPIC_MODEL="claude-sonnet-5"Enable with an OpenAI-compatible endpoint
AI_PROVIDER="openai-compatible"
AI_API_KEY="your-api-key"
AI_BASE_URL="https://api.openai.com/v1"
AI_MODEL="gpt-5.6-luna"For OpenRouter, point AI_BASE_URL at https://openrouter.ai/api/v1 and use an
OpenRouter model id.
More OpenAI-compatible providers
Any endpoint that speaks OpenAI's chat completions format works here. A few more, each with a working example.
Moonshot AI (Kimi)
AI_PROVIDER="openai-compatible"
AI_API_KEY="your-moonshot-key"
AI_BASE_URL="https://api.moonshot.ai/v1"
AI_MODEL="kimi-k3"Do not set temperature — Kimi K3 fixes it at 1.0 and rejects any other
value. Accounts on Moonshot's mainland-China platform use
https://api.moonshot.cn/v1 with a separate key instead.
Z.ai (GLM)
AI_PROVIDER="openai-compatible"
AI_API_KEY="your-zai-key"
AI_BASE_URL="https://api.z.ai/api/paas/v4"
AI_MODEL="glm-5.2"Z.ai is the current name for what was Zhipu AI. Use glm-5.2, not the newer
glm-5.3 — as of this writing GLM-5.3 is available only through Z.ai's
subscription coding plan, not the pay-per-token API.
DeepSeek
AI_PROVIDER="openai-compatible"
AI_API_KEY="your-deepseek-key"
AI_BASE_URL="https://api.deepseek.com"
AI_MODEL="deepseek-v4-pro"The older deepseek-chat and deepseek-reasoner model ids were retired. Use
deepseek-v4-flash for a faster, cheaper tier of the same model family.
Groq
AI_PROVIDER="openai-compatible"
AI_API_KEY="your-groq-key"
AI_BASE_URL="https://api.groq.com/openai/v1"
AI_MODEL="openai/gpt-oss-120b"Groq does not support the logprobs, logit_bias, or top_logprobs
parameters, and treats temperature: 0 as a very small positive number instead
of exactly zero.
Mistral AI
AI_PROVIDER="openai-compatible"
AI_API_KEY="your-mistral-key"
AI_BASE_URL="https://api.mistral.ai/v1"
AI_MODEL="mistral-medium-latest"mistral-medium-latest always points to Mistral's current mid-tier flagship
model. Pin an exact version with mistral-medium-3-5 if the response needs to
stay consistent over time.
xAI (Grok)
AI_PROVIDER="openai-compatible"
AI_API_KEY="your-xai-key"
AI_BASE_URL="https://api.x.ai/v1"
AI_MODEL="grok-4.6"xAI is now part of SpaceX and its documentation is branded SpaceXAI, but the API
endpoint, model ids, and XAI_API_KEY variable name are unchanged.
Enable with Ollama (local)
Local Ollama needs no API key.
AI_PROVIDER="ollama"
AI_MODEL="gemma4:12b"For a smaller download on memory-constrained machines, use gemma4:e2b or
gemma4:e2b-it-qat instead.
Enable with Ollama Cloud
AI_PROVIDER="ollama-cloud"
AI_API_KEY="your-ollama-cloud-key"
AI_MODEL="deepseek-v4-flash:0731"Ollama Cloud's model ids do not follow one fixed pattern: through the local
ollama CLI, cloud models take a :cloud tag (deepseek-v4-flash:cloud);
called directly at the https://ollama.com/v1 endpoint shown above, they use
the plain dated id instead, with no suffix. Check
Ollama's cloud model list for the current
id before deploying, since cloud models are retired and replaced on their own
schedule.
Provider options
AI_PROVIDERstringAI_API_KEYstringProvider API key. Optional for local Ollama.
AI_BASE_URLstringProvider base URL. Optional; sensible presets exist per provider.
AI_MODELstringModel id. Required for non-Anthropic providers.
ANTHROPIC_API_KEYstringAnthropic-specific alias for the API key.
ANTHROPIC_MODELstringAnthropic-specific model alias. Defaults to claude-sonnet-5.
Result
After setting a provider and rebuilding, the chat button appears in the bottom-right corner of every documentation page. Ask a question about the docs and the answer lists the source pages it used.
Troubleshooting
No provider is configured. Set one of the provider variable groups above and rebuild.
The model could not be resolved. Confirm the provider, key, base URL, and model are all set consistently.
The question did not match any indexed page. Rephrase using terms from the documentation.