GitHub Copilot SDK Tutorial (Python)
A step-by-step guide to building real applications with the GitHub Copilot SDK for Python.
New to the SDK? Start with the language-agnostic overview and concepts — what the GitHub Copilot SDK is and is not, plus common setup for installing the Copilot CLI and authenticating with GitHub. This page focuses on the Python edition.
Tutorial Structure
Each tutorial pairs a documentation page with a self-contained CLI script that you can run directly:
| # | Tutorial | Script | What You Learn |
|---|---|---|---|
| 1 | CLI Chatbot | 01_chat_bot.py |
CopilotClient, sessions, single prompt, interactive loop |
| 2 | Issue Triage Bot | 02_issue_triage.py |
Custom tools with @define_tool, Pydantic I/O |
| 3 | Streaming Review | 03_streaming_review.py |
Streaming with ASSISTANT_MESSAGE_DELTA |
| 4 | Skills Doc Generation | 04_skills_docgen.py |
Agent Skills via SKILL.md files |
| 5 | Audit Log | 05_audit_hooks.py |
Session hooks, permission handling |
| 6 | BYOK Azure OpenAI | 06_byok_azure_openai.py |
Bring Your Own Key with Azure OpenAI |
All scripts live in
src/python/scripts/tutorials/.
Quick Start
Make sure the Copilot CLI is installed and authenticated first — see the common Getting Started guide. Then:
# 1. Install SDK and tutorial dependencies (uses src/python/pyproject.toml)
cd src/python
uv sync --all-groups
# 2. Run your first tutorial script (the SDK launches the CLI on demand)
uv run python scripts/tutorials/01_chat_bot.py --prompt "Hello, Copilot!"
For Python-specific setup, see Getting Started (Python).
Scope
In scope:
- GitHub Copilot SDK concepts (what it is / is not)
- Architecture and operation principles
- Python SDK API design and interfaces
- Sample code and step-by-step guides for concrete use cases
- Agent Skills, Custom Tools, Session Hooks, Permission Handling, Streaming, BYOK
Out of scope:
- TypeScript / .NET SDK details (see References)
- Copilot CLI standalone usage guide
- Production scaling and infrastructure
- GitHub OAuth App authentication flow (see CopilotReportForge docs)
template_github_copilotpackage internals (tutorial scripts are self-contained)
Further Reading
| Document | Description |
|---|---|
| Overview | Language-agnostic concepts and language chooser |
| Architecture | How the SDK, CLI server, and Copilot API interact |
| Getting Started (Python) | Python-specific setup and first run |
| CLI Server Mode | Run the Copilot CLI as a standalone TCP server |
| References | API reference and external links |