Give your agents a user interface
CrewAI runs your agents. CopilotKit gives them a frontend. Together they let you build applications where users chat with a Crew or Flow, watch it work in real time, approve its decisions, and see its output rendered as live UI instead of walls of text. The two connect through the AG-UI protocol. Theag-ui-crewai package exposes any Crew or Flow as an AG-UI endpoint. CopilotKit’s React hooks and components consume that endpoint. This unlocks experiences that go well beyond a chat box:
Generative UI
Render agent tool calls and state as your own React components.
Human-in-the-Loop
Pause the agent to collect user approval or input mid-run.
Shared State
Keep agent state and your app UI in two-way sync.
Channels
Run the same agent as a Slack, Discord, or Teams bot.
Architecture
There are three pieces:- CrewAI agent server — a Python process that serves your Crew or Flow over AG-UI (FastAPI +
ag-ui-crewai). - CopilotKit runtime — a Next.js route that registers your agent and proxies requests to it.
- React frontend — the
<CopilotKit>provider plus chat and generative-UI components.
This guide covers the self-hosted path: you run the CrewAI agent server yourself with
ag-ui-crewai, and it works locally with no managed service. CopilotKit also offers a managed path (CopilotKit Cloud / Enterprise Intelligence) with hosted threads and an inspector — see the CopilotKit CrewAI quickstart if you want that instead. The frontend code in this section is the same either way; only how the agent is hosted and registered differs.CrewAI runs behind AG-UI in three shapes: regular Flows (used throughout these guides), Conversational Flows (native, session-aware, turn-based, at full feature parity), and Crews (basic chat). The frontend in this section is identical across them — only the backend authoring and registration differ.
Integration guide
1
Serve your agent over AG-UI
Install the integration package into your CrewAI project:Expose your agent from a FastAPI app. Flows use Run it:
add_crewai_flow_fastapi_endpoint; Crews use add_crewai_crew_fastapi_endpoint. You can register as many as you want, each on its own path.Set the environment variables for your LLM provider (for example
OPENAI_API_KEY) before starting the server.2
Create a Next.js app
If you do not have a frontend yet, scaffold one:Install CopilotKit and the CrewAI AG-UI client:
3
Add the CopilotKit runtime
Create a route that registers your CrewAI agent(s) with the CopilotKit runtime. Each agent points at a path on your Python server via
CrewAIAgent.4
Wrap your app with the provider
Point
<CopilotKit> at the runtime route and name the agent you registered.5
Run it
Start both processes and open the app. Chatting in the sidebar now runs your Crew or Flow.
Chat UI options
CopilotKit ships three interchangeable chat surfaces. Swap the component; the wiring is identical.Where to go next
Generative UI
Render tool calls and agent state as custom components.
Frontend Actions
Let the agent call functions that run in the browser.
Human-in-the-Loop
Gate agent actions behind user approval.
Predictive State
Stream in-progress state to the UI as the agent works.
