Overview

What is Copilot SDK

Copilot SDK lets you add AI chat to any React app. Tools execute on the frontend, giving the AI real capabilities in your app.


How It Works

Your React App
CopilotProvider
CopilotChat
Chat UI
Tools
Frontend
Context
App State
HTTP Stream
/api/chat(Backend)
LLM Provider(OpenAI, Anthropic, etc)

Key Concepts


Why Frontend Tools?

Unlike server-side tool execution, frontend tools can:

  • Access browser APIs - DOM, localStorage, navigation
  • Show rich UI - Render React components as tool results
  • Use app state - Read/write your React state directly
  • Real-time updates - Stream results as they happen

Tools run in the browser where your app lives. The AI decides what to call, your code executes it.


Quick Example

// Register a tool
useTools({
  search_products: {
    description: 'Search product catalog',
    parameters: z.object({ query: z.string() }),
    handler: async ({ query }) => {
      const results = await searchAPI(query);
      return { products: results };
    },
  },
});

// That's it - AI can now search your products

User says: "Find wireless headphones under $100"

AI calls search_products({ query: "wireless headphones" }) → Shows results.


Features

FeatureDescription
Chat UIPre-built chat with streaming, markdown, code blocks
Frontend ToolsGive AI abilities in your app
Generative UIRender React components as tool results
Smart AI ContextAI understands your app state
Agentic LoopMulti-step reasoning and tool chains
MultimodalImages, PDFs, and files in chat
4+ ProvidersOpenAI, Anthropic, Google, xAI...
Backend ToolsSecure backend tool execution
Chat HistoryPersist conversations across sessions

Next Steps

On this page