Angular
API reference for @copilotkit/angular: the CopilotKit providers, prebuilt chat components, services, and functions for building CopilotKit into an Angular app.
@copilotkit/angular provides providers, prebuilt chat components, a CopilotKit service, and standalone functions for Angular applications. Everything is built on the AG-UI agent protocol.
The package targets Angular 20, 21, and 22, and ships as standalone components
and providers. Import the main API from @copilotkit/angular. MCP Apps uses
the @copilotkit/angular/mcp-apps entry point. There is no /v2 subpath.
Installation
npm install @copilotkit/angular @angular/cdk@angular/cdk and rxjs are peer dependencies. If your agent connects directly over AG-UI, also install @ag-ui/client.
Styling
When using the prebuilt UI components, import the stylesheet once in your global styles. It is self-contained, so the chat renders without any other CSS.
@import "@copilotkit/angular/styles.css";Provider setup
Add provideCopilotKit to your application providers and configure the runtime connection there. The root CopilotKit service reads this application-level configuration.
import { ApplicationConfig } from "@angular/core";
import { provideCopilotKit } from "@copilotkit/angular";
export const appConfig: ApplicationConfig = {
providers: [
provideCopilotKit({
runtimeUrl: "/api/copilotkit",
}),
],
};To connect directly to an AG-UI agent without a runtime, pass selfManagedAgents instead of runtimeUrl:
import { ApplicationConfig } from "@angular/core";
import { provideCopilotKit } from "@copilotkit/angular";
import { HttpAgent } from "@ag-ui/client";
export const appConfig: ApplicationConfig = {
providers: [
provideCopilotKit({
selfManagedAgents: {
default: new HttpAgent({ url: "http://localhost:8000/" }),
},
}),
],
};Then drop the chat into a standalone component's template:
import { Component } from "@angular/core";
import { CopilotChat } from "@copilotkit/angular";
@Component({
selector: "app-root",
standalone: true,
imports: [CopilotChat],
template: `<copilot-chat />`,
})
export class AppComponent {}Angular conventions
CopilotKit follows Angular's dependency-injection and signal patterns:
- Register
provideCopilotKitin application providers. - Read reactive state by calling signals such as
agentStore().messages(). - Call injectable helpers from a constructor, field initializer, or another injection context.
- Import standalone components in the component
importsarray. - Customize UI with component inputs, templates, directives, and content projection.
Lifecycle and rendering environments
Injectable helpers bind their effects, subscriptions, runtime registrations,
timers, and observers to the owning Angular DestroyRef. Call them from a
field initializer, constructor, or explicit injection context. Do not cache an
injected controller beyond that injector's lifetime. Application-owned work
started inside a tool handler, such as a fetch, remains the application's
responsibility to cancel.
CopilotKit's main chat components use signals and support zoneless change
detection. Browser-only behavior is inert during server rendering and
activates after hydration. Keep configuration and
initial model/input values identical for the server and the first client
render, avoid running agents or tools on the server, and place
application-owned DOM work behind an Angular platform guard or
afterNextRender.
A2UI, Open Generative UI, audio capture, and MCP Apps can be present in an SSR tree, but their custom elements, media APIs, sandboxes, and iframes become interactive only in the browser. See Angular production and lifecycle for the full setup, cleanup, error, SSR, hydration, and zoneless contract.
API Reference
Looking for tool rendering? Start with
registerFrontendTool,
registerRenderToolCall,
and
registerHumanInTheLoop.
UI Components
Prebuilt chat, popup, sidebar, and supported component-slot primitives.
Functions
Setup providers and injectable functions for agents, tools, context, and chat labels.
Services
The CopilotKit service: the central handle on agents, tools, runtime connection, and suggestions.
Directives
The CopilotKitAgentContext directive for sharing application state with the agent from a template.
Public API Inventory
The complete root and MCP Apps export contract, including the explicitly internal extension token.