OPENAI_API_KEY
as an environment variable. This example uses gpt-4o-mini
, but you can replace it with any other model supported by AG2.
ui/app/api/copilotkit/route.ts
):
Next.js
API routesui/app/layout.tsx
):
ui/app/page.tsx
):
CopilotSidebar
component is the key UI element that adds a chat interface powered by AG2 to your application. With just these few lines of code, you get a functional chat interface that communicates with your backend agents.
To start the frontend, run the following commands in a new terminal session: