# Introduction

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

## Bring your LlamaIndex agents to your users

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

[Quickstart](/llamaindex/quickstart)

## Build with LlamaIndex

LlamaIndex gives you the agent and everything it reads: indexes, retrievers and the workflow around them. 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](/llamaindex/generative-ui): Your workflow emits events and tool calls as it runs. CopilotKit streams them to the browser and renders each one as a React component, so retrieval and reasoning are visible instead of hidden behind a spinner.
- [Human-in-the-loop](/llamaindex/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](/llamaindex/shared-state): Your workflow carries state between steps. 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 LlamaIndex too. [And more](/llamaindex/build-with-agents)

## Start building

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

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

[Read the quickstart](/llamaindex/quickstart)

## Connect your agent

Your agent keeps running as its own LlamaIndex service. The LlamaIndexAgent bridge points CopilotKit at its AG-UI endpoint, so nothing inside the agent changes.

```ts title="app/api/copilotkit/[[...slug]]/route.ts"
import {
  CopilotRuntime,
  createCopilotRuntimeHandler,
} from "@copilotkit/runtime/v2";
import { LlamaIndexAgent } from "@ag-ui/llamaindex";

const runtime = new CopilotRuntime({
  agents: {
    my_agent: new LlamaIndexAgent({ url: "http://localhost:8000/run" }),
  },
});

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

export const GET = handler;
export const POST = handler;
```

[Read the setup guide](/llamaindex/quickstart)
