AI Copilots - Copilots

AI Copilots provides a default copilot for testing, but you should define a custom copilot in the Liveblocks dashboard for further development and production. This allows you to configure your AI model, system prompt, back-end knowledge, and more.

Creating a copilot

To create a copilot, open the Liveblocks dashboard, select a project and click on the “AI Copilots” page. Click on the “Create copilot” button, and fill in the required fields.

Screenshot of the Liveblocks dashboard with the AI Copilots page and the Create copilot button

Get your API key

Copilots use API keys provided by your AI provider, which can be created and copied on their respective websites. Out of the box, we support OpenAI, Anthropic, and Google, but, you can use other OpenAI-compatible APIs, such as Groq and OpenRouter.

Add the copilot to your application

To use the new copilot in your application, copy your copilot ID from the dashboard.

Paste the copilot ID into AiChat and useSendAiMessage to start using it.

import { AiChat } from "@liveblocks/react-ui";
function Chat() { return ( <AiChat chatId="my-chat-id" copilotId="co_tUYtNctLAtUIAAIZBc1Zk" /> );}
import { useSendAiMessage } from "@liveblocks/react";
function SendMessage() { const sendAiMessage = useSendAiMessage("my-chat-id", { copilotId: "co_tUYtNctLAtUIAAIZBc1Zk", });
return ( <button onClick={() => sendAiMessage("What's new?")}>What's new?</button> );}

Configuring your copilot

Within the “General” tab you can configure a number of settings for your copilot. Settings slightly differ between providers.

Name

The name of your AI Copilot, which will be displayed in the dashboard.

Name
My AI Copilot

Provider

This is the AI provider you want to use for your copilot. You can choose from OpenAI, Anthropic, and Google, and other OpenAI-compatible APIs, such as Groq. Using an OpenAI-compatible tool like OpenRouter allows you to define fallback models.

Provider
OpenAI

Model

The AI model you want to use for your copilot, such as GPT-4.1 or Claude 4 Sonnet. You can choose from the models supported by your provider. With third-party tools you can define fallback models.

Model
GPT-4.1

Custom provider name

If you’re using an OpenAI-compatible provider, you can define a custom provider name, which you may find on your provider’s website. If a custom provider name isn’t needed by your provider, you can use any string.

Custom provider name
custom-provider

Base URL

If you’re using an OpenAI-compatible provider, you must define a base URL, which you can find on your provider’s website.

Base URL
https://openrouter.ai/api/v1/

Reasoning effort, extended thinking, thinking budget

Reasoning is supported by some models, allowing AI show its thought processes, and come up with more accurate answers. Some models allow you to select a reasoning effort, such as low, medium, or high, or a token budget for extended thinking.

Reasoning effort
low

API key

The API key for your provider. You can find keys on each provider’s website: OpenAI, Anthropic, and Google. Also supports OpenAI-compatible APIs, such as Groq and OpenRouter. All API keys are encrypted at rest, and never stored in plain text.

API key
sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

System prompt

The system prompt defines the behavior of the copilot, for example:

System prompt
You're a helpful assistant that can answer questions and help with tasks.

You can create more complex system prompts by using Markdown formatting.

System prompt
# Role and objective
You're a helpful assistant that can answer questions and help with tasks.
## Instructions
- Always help the user as best you can.- Always use markdown formatting in your responses.- If you don't know the answer, tell the user to contact support.
## Examples
User: How do I log in?Assistant: Navigate to the [login page](/login) and enter your email.
User: What's the weather in Tokyo?Assistant: I don't know the answer to that question, please contact support.

When should AI use knowledge?

This setting determines when AI will search back-end knowledge before responding.

When should AI use knowledge?
Whenever the user asks a question about code.

You can also write a more complex prompt, giving knowledge a name, which then allows you to refer to it in your system prompt. This can help reinforce AI behavior.

When should AI use knowledge?
Whenever the user asks a question about code.
This is your **knowledge base**.
System prompt
## Instructions
- When a user asks about React, searching your **knowledge base** is required....

Adding back-end knowledge

Under the “Knowledge” tab you can add back-end knowledge to your copilot. Knowledge can be submitted as web pages or files, and your AI chat can query this knowledge when responding, allowing it to intelligently answer questions or perform tasks.

Screenshot of the Liveblocks dashboard, adding knowledge to a copilot

You can submit a whole website/sitemap for crawling, a single page, or PDF/image files. Crawled knowledge is not updated, and to update it, it must be resubmitted programmatically or via the dashboard.

Configuring advanced settings

Under the “Advanced” tab you can configure a number of advanced settings for your copilot. By default, Liveblocks does not pass default values to your provider, and leaves the options blank.

SettingDescriptionExample value
Max tokens Controls response length1024
Temperature Controls randomness in responses0.2
Top P Alternative to temperature for controlling randomness0.9
Top K Advanced sampling control200
Presence penalty Controls repetition of existing content0.3
Frequency penalty Controls repetition of words and phrases0.3
Stop sequences Controls when text generation stops["\\n\\n", "Human:"]
Seed Controls randomness for reproducible results42
Max retries Controls how many times to retry failed requests2

Modifying copilots programmatically

You aren’t limited to creating copilots from the dashboard—you can also create and modify copilots programmatically, allowing users or teams in your app to have their own individual copilots.

import { Liveblocks } from "@liveblocks/node";
const liveblocks = new Liveblocks({ secret: "",});
const copilot = await liveblocks.createAiCopilot({ name: "My AI Assistant", systemPrompt: "You're a helpful assistant that can answer questions.", provider: "openai", providerModel: "gpt-4", providerApiKey: "sk-...",});

This is made possible using the Liveblocks Node.js client and REST API, where a number of APIs are available for managing copilots.

You can also manage each copilot’s knowledge sources.

We use cookies to collect data to improve your experience on our site. Read our Privacy Policy to learn more.