Skip to content

Production-ready AI Copilots for any product. Connect any LLM, deploy on your infrastructure, own your data. Built for speed and control.

License

Notifications You must be signed in to change notification settings

YourGPT/copilot-sdk

Repository files navigation

Copilot SDK

Build AI Copilots for Your Product

Production-ready AI Copilots for any product. Connect any LLM, deploy on your infrastructure, own your data. Built for speed and control.

npm version npm downloads MIT License

Documentation


Copilot SDK Demo

Quick Start

Install

npm install @yourgpt/copilot-sdk @yourgpt/llm-sdk openai

Frontend (React)

import { CopilotProvider } from "@yourgpt/copilot-sdk/react";
import { CopilotChat } from "@yourgpt/copilot-sdk/ui";
import "@yourgpt/copilot-sdk/ui/styles.css";

function App() {
  return (
    <CopilotProvider runtimeUrl="/api/chat">
      <YourApp />
      <CopilotChat />
    </CopilotProvider>
  );
}

Backend (Next.js)

// app/api/chat/route.ts
import { streamText } from "@yourgpt/llm-sdk";
import { openai } from "@yourgpt/llm-sdk/openai";

export async function POST(req: Request) {
  const { messages } = await req.json();

  const result = await streamText({
    model: openai("gpt-4o"),
    system: "You are a helpful assistant.",
    messages,
  });

  return result.toTextStreamResponse();
}

LLM SDK - Multi-Provider Support

Use any LLM provider with a unified API:

import { streamText } from "@yourgpt/llm-sdk";
import { openai } from "@yourgpt/llm-sdk/openai";
import { anthropic } from "@yourgpt/llm-sdk/anthropic";
import { google } from "@yourgpt/llm-sdk/google";
import { xai } from "@yourgpt/llm-sdk/xai";

// OpenAI
await streamText({ model: openai("gpt-4o"), messages });

// Anthropic
await streamText({ model: anthropic("claude-sonnet-4-20250514"), messages });

// Google Gemini (uses OpenAI-compatible API)
await streamText({ model: google("gemini-2.0-flash"), messages });

// xAI Grok (uses OpenAI-compatible API)
await streamText({ model: xai("grok-3-fast-beta"), messages });

SDK Requirements

Provider SDK Required
OpenAI, Google, xAI openai
Anthropic @anthropic-ai/sdk

Server-Side Tools

Add tools to let the AI call functions on your server:

import { streamText, tool } from "@yourgpt/llm-sdk";
import { openai } from "@yourgpt/llm-sdk/openai";
import { z } from "zod";

const result = await streamText({
  model: openai("gpt-4o"),
  messages,
  tools: {
    getWeather: tool({
      description: "Get current weather for a city",
      parameters: z.object({
        city: z.string().describe("City name"),
      }),
      execute: async ({ city }) => {
        const data = await fetchWeatherAPI(city);
        return { temperature: data.temp, condition: data.condition };
      },
    }),
  },
  maxSteps: 5,
});

return result.toDataStreamResponse();

Packages

Package Description
@yourgpt/copilot-sdk/react React hooks and provider
@yourgpt/copilot-sdk/ui Pre-built chat components
@yourgpt/copilot-sdk/core Core utilities and context capture tools
@yourgpt/llm-sdk Multi-provider LLM SDK with streaming

Documentation

Visit copilot-sdk.yourgpt.ai for full documentation.


Contributing

Have any feedback? Share it with us.

@0fficialRohit · @rege_dev


License

MIT License

About

Production-ready AI Copilots for any product. Connect any LLM, deploy on your infrastructure, own your data. Built for speed and control.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •