Loading...
Loading...
@copilotkit/runtime — mount a fetch-native CopilotRuntime on any JS server, wire middleware, pick an AgentRunner, instantiate BuiltInAgent (Factory Mode with TanStack AI is the preferred default) or plug in any of 12 external agent frameworks (Mastra, LangGraph, CrewAI Crews/Flows, PydanticAI, ADK, LlamaIndex, Agno, AWS Strands, MS Agent Framework, AG2, A2A), enable Intelligence mode for durable threads + websocket, register server-side tools via defineTool, and wire voice transcription. Uses the fetch-based createCopilotRuntimeHandler primitive — the Express/Hono adapters are discouraged. Load the reference under references/ that matches your task.
npx skill4agent add copilotkit/copilotkit runtime@copilotkit/runtimeAbstractAgentAgentRunnerreferences/CopilotRuntimenew CopilotRuntime({
agents, // Record<string, AbstractAgent> — see wiring-external-agents or built-in-agent
runner, // AgentRunner (optional) — see agent-runners
intelligence, // CopilotKitIntelligence (optional) — see intelligence-mode (auto-wires runner)
mcpApps, // McpAppsConfig (optional) — see wiring-mcp-apps-middleware
a2ui, // A2UIConfig (optional) — see packages/a2ui-renderer skill
hooks, // { onRequest, onBeforeHandler } — see middleware
beforeRequestMiddleware,
afterRequestMiddleware, // legacy — see middleware
transcription, // TranscriptionService (optional) — see transcription
});import { createCopilotRuntimeHandler } from "@copilotkit/runtime/v2";
const handler = createCopilotRuntimeHandler({
runtime,
basePath: "/api/copilotkit",
});
export default { fetch: handler };| Task | Reference |
|---|---|
| Mounting on any fetch-native server (Cloudflare Workers, Bun, Deno, Vercel Edge, Next.js App Router, React Router v7, TanStack Start) or delegating from Express/Node | |
Auth / logging / rate-limit / request-scoped guards via | |
Choosing between | |
| Enabling durable threads + realtime websocket via CopilotKit Cloud (Intelligence is Cloud-only, not self-hostable) | |
Voice transcription — implementing a | |
Instantiating | |
Defining server-side tools via | |
Wiring an external agent framework into | |
| Wiring MCP Apps (runtime-level middleware, not an agent) | |
createCopilotRuntimeHandlercreateCopilotExpressHandlercreateCopilotHonoHandlerpublicLicenseKeypublicApiKeyIntelligenceAgentRunnerrunnerintelligenceCopilotRuntimeapi.cloud.copilotkit.aihooks.onRequestbeforeRequestMiddlewarebeforeRequestMiddlewarehooks.onRequestfetch-handler.ts:136-147identifyUserResponsehooks.onRequestagents__unsafe_dev_onlyselfManagedAgentssetup-endpointbuilt-in-agentwiring-external-agentsagent-runnersmiddlewareintelligence-modeserver-side-toolstranscription