Angular
Connect an Angular app to Copilot Runtime with CopilotKit.
This guide takes an Angular app to a working chat UI backed by Copilot Runtime. When you select an agent backend in the sidebar, the backend step below changes with it. Without a selection, the guide uses CopilotKit's BuiltInAgent.
The runtime runs on your server, keeps model credentials out of the browser, and exposes the default agent that CopilotChat uses automatically.
Start with your coding agent
Use this prompt to connect your Angular app to Copilot Runtime with the selected agent backend, then verify a working conversation. You can also follow the manual steps below.
Open your coding agent in your project's folder, or in an empty folder for a new app.This runs in a coding agent on your computer.
Prerequisites
- An OpenAI API key (or another model provider supported by Model Selection)
- Angular 22
- Node.js 22
Getting started
Create your Angular app
If you don't have one already, pin the CLI to the supported major:
npx @angular/cli@22 new my-copilot-app
cd my-copilot-appInstall CopilotKit
@copilotkit/angular gives you Angular components, directives, and services for CopilotKit. It supports zoneless applications. Install it with @angular/cdk, and install @copilotkit/runtime for your local Copilot Runtime server:
npm install @copilotkit/angular @angular/cdk @copilotkit/runtime
npm install -D tsx typescript @types/nodeMatch @angular/cdk to your Angular version
@angular/cdk must share your Angular major version. Most package managers resolve this for you, but if you hit a peer-dependency error, pin it explicitly (for example @angular/cdk@^22).
Connect the selected agent backend
First, add CopilotKitMiddleware to your create_agent call. The middleware
is what makes every CopilotKit feature on the frontend — frontend tools,
shared state, agent context, and generative UI components — visible to your
LangGraph agent on every turn.
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from copilotkit import CopilotKitMiddleware
graph = create_agent(
model=ChatOpenAI(reasoning_effort="none", model="gpt-6-luna"),
tools=[],
middleware=[CopilotKitMiddleware()],
system_prompt="You are a helpful, concise assistant.",
)If copilotkit isn't already in your project, add it so the import
above resolves. Pick the package manager that matches your project:
uv add copilotkitExpose the selected backend through Copilot Runtime
Configure Copilot Runtime to register this backend as the default
agent at /api/copilotkit. Continue with the selected backend's
Copilot Runtime guide for its runtime
adapter, credentials, and server command. Do not replace it with the
BuiltInAgent server from the standalone Angular path.
Import the styles
Add the package stylesheet to your global styles. It's self-contained, so the chat renders without any other CSS.
@import "@copilotkit/angular/styles.css";Connect to Copilot Runtime
Point provideCopilotKit at the runtime endpoint. The chat uses the agent that your runtime registers as default.
import { ApplicationConfig } from "@angular/core";
import { provideCopilotKit } from "@copilotkit/angular";
export const appConfig: ApplicationConfig = {
providers: [
provideCopilotKit({
runtimeUrl: "http://localhost:8200/api/copilotkit",
}),
],
};Add the chat UI
Import the CopilotChat component into your root component and drop it into the template.
import { Component } from "@angular/core";
import { CopilotChat } from "@copilotkit/angular";
@Component({
selector: "app-root",
imports: [CopilotChat],
template: `
<div style="height: 100vh">
<copilot-chat />
</div>
`,
})
export class App {}Run the backend, runtime, and Angular app
Start the selected agent backend and Copilot Runtime with the commands
from its runtime guide. Confirm
http://localhost:8200/api/copilotkit/info reports the default
agent, then start Angular:
npm startOpen the Angular CLI URL (usually http://localhost:4200) and send a
message. The request now follows the selected path end to end:
Angular → Copilot Runtime → your selected agent backend.
Open Inspector and confirm setup
On localhost, click the Inspector button in the corner of the app.
- Open Inspect, then Agent. Your agent is listed.
- Send a chat message. Open Inspect, then AG-UI Events. Events are moving.
- Open Rich Threads. The list is unlocked (Intelligence is on), or locked with Copy setup prompt (Intelligence is off).
More detail: Inspector.
Next steps
- Prebuilt Components: choose a chat surface, then follow the sidebar to frontend tools, generative UI, human-in-the-loop, shared state, threads, attachments, and headless UI.
- Runtime and backend docs: configure the server, secure requests, and deploy without leaving the selected Angular surface.
Later:
- CopilotKit Intelligence: add threads, inspection, and cloud-hosted or self-hosted operations.
- Angular API reference: use components, signals, tools, context, and runtime services.
- Production and lifecycle: handle cleanup, errors, server rendering, hydration, zoneless Angular, and browser-only features.
How is this guide?