The AI assistant web component adds the AI assistant of your Redocly project to any website, for example your app or your support portal. Users ask questions on your site, and the assistant answers from your docs.
By default, the assistant uses only the content that anonymous users can read. To use protected content, send identity tokens.
- 1
Allow requests from your site
You must have the Admin role in the project.
- In the Redocly platform, open your project, and select Settings > Environment variables.
- Add the
REDOCLY_CORS_ORIGINSvariable with the address of your site as the value, for examplehttps://app.acme.com. To allow more sites, separate the addresses with commas.
- 2
Redeploy the project
- Navigate to Deployments.
- On the latest production deployment, select More actions > Redeploy. The variable takes effect after the redeploy.
- 3
Add the snippet
- Configure the assistant in the playground.
- Follow the install steps under the preview.
Install AI assistant
- 1
Enter the URL of your Redocly project.
- 2
Copy the snippet to your site.
index.html<script src="https://cdn.redocly.com/ai-assistant/releases/latest/main.js"></script> <redocly-ai-assistant api-url="https://your-project.com" color-mode="system" welcome-message="Hi! Ask me anything about these docs." suggestions='["How do I get started?","How do I authenticate?"]' ></redocly-ai-assistant>
See the AI assistant web component options to reference all available attributes.
The script adds the window.RedoclyAssistant object to your page. Use it in your scripts after the <script> tag of the assistant. The examples below show some common uses.
For all the methods, keys, and events, see Web component API.
To change the colors and the font, set CSS variables on the redocly-ai-assistant element:
redocly-ai-assistant {
--font-family-base: 'Inter', sans-serif;
--button-bg-color-primary: #0f766e;
--search-ai-user-bg-color: #0f766e;
}
See CSS variables to reference all available variables.
The assistant can display a Contact support button that sends the conversation to your support team by email. To turn it on, see Configure AI assistant support escalation.
Something went wrong
The browser blocks the request to your project. The browser console shows a CORS error.
- Make sure that
REDOCLY_CORS_ORIGINShas the exact address of your site: the scheme, the host, and the port. Wildcards, such as*, do not work. - Redeploy the project after you change the variable.
- If your project uses a path prefix, add the prefix to
api-url, for examplehttps://acme.com/docs. - Each IP address can send 25 requests in 5 minutes.
Authentication Required
The project does not let anonymous users use the AI assistant. If you set access.rbac.features.aiSearch, add anonymous: read to it.
Feature Unavailable
The AI assistant is off for the project. Make sure that aiAssistant.hide is not true in redocly.yaml, and that your plan includes the AI assistant web component.
The assistant does not use your docs
- The content requires login. Send identity tokens.
- The
locale,product, or version attributes do not match your content. - The pages are new. The assistant uses a page only after the next production deployment.
The Ask AI button does not show
- The
api-urlattribute is missing. The browser console displays a warning. - The Content Security Policy of your site blocks the script. See Content Security Policy.
- AI assistant web component configuration - Every attribute, method, event, and CSS variable of the assistant
- Answer from login-protected content - Let the assistant use protected content for the users who sign in to your site
- Configure AI assistant support escalation - Let users send a conversation to your support team
- Analytics - See the questions that users ask and how they rate the answers