Overview

What is YourGPT Copilot SDK

Copilot Overview

YourGPT 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 App                                                       │
│  ┌─────────────────────────────────────────────────────────┐   │
│  │  YourGPTProvider                                         │   │
│  │  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐   │   │
│  │  │  CopilotChat │  │    Tools     │  │   Context    │   │   │
│  │  │              │  │  (Frontend)  │  │   (State)    │   │   │
│  │  └──────────────┘  └──────────────┘  └──────────────┘   │   │
│  └─────────────────────────────────────────────────────────┘   │
│                              ↕                                  │
│                       /api/chat (Backend)                       │
│                              ↕                                  │
│                      LLM Provider (OpenAI, 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
Custom ToolsGive AI abilities in your app
Generative UIRender React components as tool results
Context AwarenessAI understands your app state
Agentic LoopMulti-step reasoning and tool chains
MultimodalImages, PDFs, and files in chat
7+ ProvidersOpenAI, Anthropic, Google, Groq, Ollama...
Server ActionsSecure backend tool execution
Knowledge BaseRAG with your documents

Next Steps

On this page