# Introduction

> Bring your AG2 agents to your users with CopilotKit via AG-UI.

## Bring your AG2 agents to your users

AG2 runs your agents. CopilotKit gives them a surface your users can see, interrupt and steer.

[Quickstart](/ag2/quickstart)

## Build with AG2

AG2 gives you the conversation between your agents: roles, turns and the tools they call. What it does not give you is the surface a person joins it through. Each capability below builds on something your agents already do.

- [Generative UI](/ag2/generative-ui): Your agents call tools as the conversation runs. CopilotKit streams those calls to the browser and renders each one as a React component, instead of leaving the user with a spinner.
- [Human-in-the-loop](/ag2/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](/ag2/shared-state): Your agents carry state across turns. CopilotKit mirrors it into your app and back, so changes from the user and the agent go to the same state.

Chat surfaces, headless UI, frontend tools and multi-agent flows work with AG2 too. [And more](/ag2/build-with-agents)

## Start building

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

```bash
npx copilotkit@latest init
```

[Read the quickstart](/ag2/quickstart)

## Connect your agent

Your agents keep running as their own Python service, with AGUIStream from ag2.ag_ui in front of them. CopilotKit reaches that service over HTTP, so nothing inside AG2 changes.

```ts title="app/api/copilotkit/[[...slug]]/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](/ag2/quickstart)
