Skip to main content

GitHub All-Stars #4 - CopilotKit: Solving the “Last Mile” Problem for AI Agents

Picture of Artur Skowroński, Head of Java/Kotlin Space

Artur Skowroński

Head of Java/Kotlin Space
Sep 17, 2025|18 min read
triangle_shaped_tunnel
vendor_cloud_meme

1import { CopilotKit } from "@copilotkit/react-core";
2
3export default function RootLayout({ children }) {
4 return (
5 <html lang="en">
6 <body>
7 <CopilotKit publicApiKey="<your-public-api-key>">
8 {children}
9 </CopilotKit>
10 </body>
11 </html>
12 );
13}
1useCopilotReadable({
2 description: "The current spreadsheet data",
3 value: spreadsheetData,
4});
1useCopilotAction({
2 name: "sortHouseListings",
3 description: "Sort the displayed house listings",
4 parameters: {
5 type: "object",
6 properties: {
7 columnId: { type: "string", description: "Column to sort by" },
8 sortDirection: { type: "string", enum: ["asc", "desc"] },
9 },
10 required: ["columnId", "sortDirection"],
11 },
12 handler: async ({ columnId, sortDirection }) => {
13 sortColumn(columnId, sortDirection);
14 },
15});
1import {
2 CopilotRuntime,
3 OpenAIAdapter,
4 copilotRuntimeNextJSAppRouterEndpoint,
5} from "@copilotkit/runtime";
6import { NextRequest } from "next/server";
7
8export async function POST(req: NextRequest): Promise<Response> {
9 const runtime = new CopilotRuntime();
10 const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
11 runtime,
12 serviceAdapter: new OpenAIAdapter(),
13 });
14 return handleRequest(req);
15}
screenshot_ CopilotKit_2

Image: Example UI for document generation powered by CopilotKit

1useCopilotAction({
2 name: "ApprovePlan",
3 parameters: {
4 type: "object",
5 properties: {
6 planSteps: { type: "array", items: { type: "string" } },
7 },
8 required: ["planSteps"],
9 },
10 renderAndWait: ({ args, handler }) => (
11 <ConfirmPlan
12 planSteps={args.planSteps}
13 onApprove={() => handler({ approved: true })}
14 onDeny={() => handler({ approved: false })}
15 />
16 ),
17});
github_star

Subscribe to our newsletter and never miss an article