docs/content/docs/reference/v1/classes/CopilotRuntime.mdx
{ /*
This is the reference for the CopilotRuntime class. For more information and example code snippets, please see Copilot Runtime.
</Callout>
import { CopilotRuntime } from "@copilotkit/runtime";
const copilotKit = new CopilotRuntime();
Enable the A2UI middleware to let agents generate rich, interactive UI components at runtime.
a2uiboolean | object (optional)
Pass true to enable with defaults, false or omit to disable, or an object to customise behaviour.
// Enable with defaults
const runtime = new CopilotRuntime({
agents,
a2ui: true,
});
// Customise
const runtime = new CopilotRuntime({
agents,
a2ui: {
agents: ["my-agent"],
schema: [
{
name: "TodoCard",
description: "A card displaying a todo item",
props: { title: { type: "string" }, done: { type: "boolean" } },
},
],
injectA2UITool: true,
},
});
When a2ui is configured the runtime reports a2uiEnabled: true from the /info endpoint, which tells the frontend to activate the built-in A2UI renderer automatically.
| Option | Type | Description |
|---|---|---|
agents | string[] | Optional. Limit the middleware to these named agents. Applies to all agents if omitted. |
schema | A2UIComponentSchema[] | Optional. Declares which components are available to agents. Injected as context into RunAgentInput. |
injectA2UITool | boolean | string | Optional. true injects a tool named "render_a2ui". A string injects the tool with a custom name. false or omitted means no tool injection. |
a2uiToolNames | string[] | Optional. Tool names the middleware recognizes as A2UI rendering tools. Defaults to ["render_a2ui"]. |