Copilot SDK
Embed GitHub Copilot’s AI capabilities into your own applications. The SDK manages a Copilot CLI process and communicates via JSON-RPC - you control sessions, tools, and streaming programmatically.
Overview
The SDK doesn’t call the Copilot API directly. It spawns a Copilot CLI subprocess and talks to it via JSON-RPC over stdio. The CLI handles authentication, model selection, and API communication.
┌─────────────────┐ JSON-RPC ┌──────────────┐ API ┌─────────────┐
│ Your App │ <───────────────> │ Copilot CLI │ <──────────> │ Copilot │
│ (uses SDK) │ (stdio) │ (runtime) │ │ Service │
└─────────────────┘ └──────────────┘ └─────────────┘
Three layers:
- Client (
CopilotClient) - spawns the CLI, manages the connection, creates sessions - Session (
CopilotSession) - an independent conversation with its own history, system prompt, and tools - Tools - functions you define that Copilot can call to take actions
| Copilot CLI/VS Code | Copilot SDK |
|---|---|
| Interactive chat | Programmatic control |
| Human types prompts | Your app sends messages |
| Human reads responses | Your app processes events |
| Built-in tools only | Define your own tools |
| Single conversation | Multiple concurrent sessions |
Contents
- Concepts - How the SDK works
- Architecture - System overview, client-session-tool layers
- Sessions - Managing conversations with Copilot
- Tools - Extending Copilot with custom capabilities
- Events & Streaming - Real-time response handling
- Quickstart - Get a Copilot-powered app running in minutes
- Deep Dives - Advanced patterns
- Notes - Personal gotchas and experiment results
- Experiments - Experiment ideas and findings