AI chat widget
Add a conversational AI assistant to your documentation site to help users find answers.
The Stainless Docs Platform includes an optional AI-powered chat widget that allows users to ask questions in natural language and receive contextual answers based on your documentation content.
How it works
Section titled “How it works”The built-in AI chat widget appears as a collapsible input field in the bottom-right corner of your documentation site. When users type a question, the widget:
- Sends the query to the Stainless AI backend
- Searches your indexed documentation for relevant content
- Generates accurate, SDK-aware responses using Retrieval-Augmented Generation (RAG)
- Streams the response to the user in real-time
The AI assistant understands your SDK structure, API endpoints, and documentation content, providing answers that are tailored to your specific API.
Enabling the built-in chat
Section titled “Enabling the built-in chat”To enable the Stainless-provided AI chat widget in your astro.config.ts file, add the aiChat configuration:
import { defineConfig } from "astro/config";import { stainlessDocs } from "@stainless-api/docs";import aiChat from "@stainless-api/docs-ai-chat/plugin";
export default defineConfig({ integrations: [ stainlessDocs({ title: "My API Docs",
experimental: { aiChat: aiChat(), },
// ... other options }), ],});After you save the configuration and rebuild your site, the AI chat widget appears in the bottom-right corner of your documentation pages.
Features
Section titled “Features”The built-in AI chat widget includes:
- Streaming responses: Answers appear in real-time as they are generated
- Markdown rendering: Responses include formatted text, code blocks with syntax highlighting, and tables
- Tool visibility: Users can see when the AI searches your documentation
- Feedback collection: Thumbs up/down buttons allow users to rate responses
- Copy to clipboard: Users can copy responses for use elsewhere
- Keyboard shortcuts: Press
Escapeto close the chat interface
Using a custom chat widget
Section titled “Using a custom chat widget”If you prefer to use your own AI assistant or chatbot instead of the built-in Stainless chat widget, you can implement a custom chat interface. This allows you to use a different AI model, custom backend, or branded chat experience.
For an example of how to build a custom chat widget in Astro, see the AI Chat Bot theme on Astro.
Examples
Section titled “Examples”The following documentation sites use the Stainless AI chat widget:
Disabling the chat widget
Section titled “Disabling the chat widget”If you have enabled the AI chat but want to disable it, remove or comment out the aiChat configuration from your astro.config.ts file:
export default defineConfig({ integrations: [ stainlessDocs({ title: "My API Docs",
experimental: { aiChat: aiChat(), }, }), ],});