CopilotKit + OpenAI Agents SDK

Bring your OpenAI Agents SDK agents
into any app

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

Quickstart

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.

Loading Chat…

Build with OpenAI Agents SDK

The Agents SDK gives you the agent: a model, its tools, guardrails and handoffs, run in a loop. What it does not give you is the surface. Somewhere for the conversation to happen, a way to show the run while it is running, and a moment for a person to step in. Each capability below builds on something your agent already does.

Generative UI

Your function tools run on the server, and their calls stream to the browser while the model writes them. CopilotKit renders each one as a an Angular component instead of leaving the user with a spinner.

Read the docs Live demo

Human-in-the-loop

Mark a tool `needs_approval=True` and the SDK pauses before it runs. CopilotKit shows the user the call, and their answer resumes the run with nothing kept on the server in between.

Read the docs Live demo

Shared state

The page's state reaches every run, and a tool that changes it streams the new value back before its own result. Your UI and your agent work on the same data.

Read the docs Live demo

Frontend tools, app context, state streaming, reasoning, attachments, A2UI and sub-agents work with the OpenAI Agents SDK too. And more

Start building

Connect an existing agent or build a new one. Get a tailored setup prompt.

What are you building?

Tell us what you already have. We’ll tailor your setup.

Connect your agent

Your agent keeps running as its own Python service, with the ag-ui-openai-agents adapter in front of it. CopilotKit reaches that service over HTTP, so nothing inside the agent changes.

import { HttpAgent } from "@ag-ui/client";
import {
  CopilotRuntime,
  createCopilotRuntimeHandler,
} from "@copilotkit/runtime/v2";
import type { NextRequest } from "next/server";

const runtime = new CopilotRuntime({
  agents: {
    openai_agent: new HttpAgent({
      url: process.env.AGENT_URL ?? "http://localhost:8000/agent",
    }),
  },
});

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

export const POST = (req: NextRequest) => handler(req);
Read the setup guide