# Introduction

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

## Bring your Pydantic AI agents to your users

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

[Quickstart](/pydantic-ai/quickstart)

## Build with Pydantic AI

Pydantic AI gives you the agent and the types around it: validated tools, typed results and the dependencies you hand in. What it does not give you is the surface. Your users need a place to talk to the agent, a view of the run while it works, and a way to step in. Each capability below builds on something your agent already does.

- [Generative UI](/pydantic-ai/generative-ui): Your agent calls typed tools as it 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](/pydantic-ai/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](/pydantic-ai/shared-state): Your agent carries state between turns. CopilotKit mirrors it into your app and back, so a change from the user and a change from the agent go to the same state.

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

## Start building

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

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

[Read the quickstart](/pydantic-ai/quickstart)

## Connect your agent

Your agent keeps running as its own Python service, with the AGUIAdapter from pydantic_ai.ui.ag_ui in front of it. CopilotKit reaches that service over HTTP, so nothing inside the agent 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](/pydantic-ai/quickstart)
