Skip to main content

AI Chat

4 min readStableIntermediate

OwnDocs ships an AI chat widget that answers questions about your documentation and cites the pages it uses. This page shows you how to pick a provider, set its environment variables, and check that the widget works. Until you configure a provider the widget stays hidden, 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. The reader's browser keeps every chat thread locally.

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 you build.

Steps

  1. Pick a provider

    Each provider below has its own variable group. Anthropic is the default when AI_PROVIDER is unset.

  2. Add the variables to .env.local

    Copy the group for your provider from the sections below into .env.local at the repository root.

  3. Rebuild and restart

    Each page decides at build time whether to render the widget, so a restart on its own won't pick up a new provider.

    Bash
    Bash
    npm run build
    npm start

Enable with Anthropic

Anthropic is the default when no AI_PROVIDER is set.

.env.local
Bash
ANTHROPIC_API_KEY="your-anthropic-key"
ANTHROPIC_MODEL="claude-sonnet-5"

Enable with an OpenAI-compatible endpoint

Every provider in this section speaks OpenAI's chat completions format, so they all take the same four variables: the provider name, your application programming interface (API) key, the base URL, and the model id. The block below targets OpenAI itself.

.env.local
Bash
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 any other provider, keep the first two lines and swap in the base URL and model id below. OpenRouter, for instance, uses https://openrouter.ai/api/v1 with an OpenRouter model id.

Moonshot AI (Kimi)

Use https://api.moonshot.ai/v1 with model kimi-k3. Leave temperature unset: Kimi K3 fixes it at 1.0 and rejects any other value. If your account sits on Moonshot's mainland-China platform, use https://api.moonshot.cn/v1 and a separate key instead.

Z.ai (GLM)

Use https://api.z.ai/api/paas/v4 with model glm-5.2. Z.ai is the current name for what was Zhipu AI. Pick glm-5.2 rather than the newer glm-5.3: as of this writing you can reach GLM-5.3 only through Z.ai's subscription coding plan, not the pay-per-token API.

DeepSeek

Use https://api.deepseek.com with model deepseek-v4-pro. DeepSeek retired the older deepseek-chat and deepseek-reasoner ids. Switch to deepseek-v4-flash when you want a faster, cheaper tier of the same model family.

Groq

Use https://api.groq.com/openai/v1 with model openai/gpt-oss-120b. Groq does not support the logprobs, logit_bias, or top_logprobs parameters, and it treats temperature: 0 as a very small positive number rather than exactly zero.

Mistral AI

Use https://api.mistral.ai/v1 with model mistral-medium-latest, which always points to Mistral's current mid-tier flagship model. Pin an exact version with mistral-medium-3-5 when you need the response to stay consistent over time.

xAI (Grok)

Use https://api.x.ai/v1 with model grok-4.6. xAI is now part of SpaceX and its documentation carries the SpaceXAI brand, but the API endpoint, model ids, and XAI_API_KEY variable name are unchanged.

Enable with Ollama (local)

Local Ollama needs no API key.

.env.local
Bash
AI_PROVIDER="ollama"
AI_MODEL="gemma4:12b"

If the machine is short on memory, pick gemma4:e2b or gemma4:e2b-it-qat for a smaller download.

Enable with Ollama Cloud

.env.local
Bash
AI_PROVIDER="ollama-cloud"
AI_API_KEY="your-ollama-cloud-key"
AI_MODEL="deepseek-v4-flash:0731"

Watch the model id here, because Ollama Cloud follows no fixed pattern. Through the local ollama CLI, cloud models take a :cloud tag (deepseek-v4-flash:cloud). Called directly at https://ollama.com/v1, they use the plain dated id with no suffix. Check Ollama's cloud model list before you deploy, because Ollama retires and replaces cloud models on its own schedule.

Provider options

The Configuration page lists every AI_* and ANTHROPIC_* variable with its type, default, and description.

Result

Once you set a provider and rebuild, 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

You have no provider configured. Set one of the provider variable groups above and rebuild.

OwnDocs could not resolve the model. Confirm the provider, key, base URL, and model are all set consistently.

Your question did not match any indexed page. Rephrase it using terms from the documentation.

Was this page helpful?

© 2026 DevOps. All rights reserved.