CopilotKit + Open Agent Spec

Bring your Open Agent Spec agentsinto any app

CopilotKit is an open-source framework that connects your app to Open Agent Spec agents. Give your agents chat, generative UI, human-in-the-loop, AG-UI Streams, Automatic Learning and more.

Quickstart
AG-UI Streams

Waking up the demo

Keep conversations, UI, and tool activity across sessions.

Build with Open Agent Spec

Open Agent Spec describes an agent in a form other tools can run. What it does not describe is the surface your users work in. Each capability below builds on what a running spec already emits.

Generative UI

Your agent's tool calls arrive as they happen. CopilotKit renders each one as a React component in your own app, instead of leaving the user with a spinner.

Human-in-the-loop

A frontend tool registered with useHumanInTheLoop renders your own UI, waits for the user's answer, and hands it back to the agent as the tool result.

Shared state

Your agent carries state between turns. CopilotKit mirrors it into your app and back, so a user edit and an agent write land in the same place.

Chat surfaces, headless UI, frontend tools and multi-agent flows work with Open Agent Spec too. And more

Start building

Scaffold a new app with the CLI, or follow the quickstart to connect the Open Agent Spec agent you already run.

npx copilotkit@latest init
Read the quickstart

Connect your agent

Your agent keeps running where it runs today, behind an AG-UI endpoint. CopilotKit reaches it over HTTP, so nothing inside the agent changes.

app/api/copilotkit/route.ts
import {
  CopilotRuntime,
  createCopilotRuntimeHandler,
} from "@copilotkit/runtime/v2";
import { HttpAgent } from "@ag-ui/client";

const runtime = new CopilotRuntime({
  agents: {
    my_agent: new HttpAgent({ url: process.env.AGENT_URL! }),
  },
});

const handler = createCopilotRuntimeHandler({
  runtime,
  basePath: "/api/copilotkit",
});

export const GET = handler;
export const POST = handler;
Read the setup guide

How is this guide?