Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build custom Copilot extensions and AI agents using the Azure-hosted GitHub Copilot SDK
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/copilot-sdk.md
1# Copilot SDK Reference23## Template45```bash6azd init --template azure-samples/copilot-sdk-service7```89**Architecture:** API (Express/TS) + Web UI (React/Vite), deployed as 2 Container Apps. Chat endpoint streams token-level deltas via `assistant.message_delta` SSE events. Azure BYOM gets a fresh bearer token per-request (no expiry issues).1011## Documentation1213| Resource | URL |14|----------|-----|15| Overview & Getting Started | https://github.com/github/copilot-sdk |16| Getting Started Guide | https://github.com/github/copilot-sdk/blob/main/docs/getting-started.md |17| Node.js SDK | https://github.com/github/copilot-sdk/tree/main/nodejs |18| Python SDK | https://github.com/github/copilot-sdk/tree/main/python |19| Go SDK | https://github.com/github/copilot-sdk/tree/main/go |20| .NET SDK | https://github.com/github/copilot-sdk/tree/main/dotnet |21| Debugging | https://github.com/github/copilot-sdk/blob/main/docs/debugging.md |22| Compatibility | https://github.com/github/copilot-sdk/blob/main/docs/compatibility.md |2324## Getting Current Examples2526Use `github-mcp-server-get_file_contents` with `owner: "github"`, `repo: "copilot-sdk"` to read files directly from the repo and get current SDK documentation and code examples.2728If the **context7** MCP server is available, it can also be used to query SDK docs:29301. Call `context7-resolve-library-id` with `libraryName: "copilot-sdk"` to find the library ID312. Call `context7-query-docs` with the resolved ID and a query matching the user's goal323. Select the most relevant snippets for the user's scenario3334> ๐ก **Tip:** If context7 is not installed, instruct the user to add it. For a quick one-off use: `npx -y @upstash/context7-mcp@latest`. To persist it, add `@upstash/context7-mcp` as an entry in their MCP server configuration file.3536## Three Model Paths3738| Path | Config | Auth |39|------|--------|------|40| GitHub default | No `model` param | `GITHUB_TOKEN` |41| GitHub specific | `model: "<name>"` | `GITHUB_TOKEN` |42| Azure BYOM | `model` + `provider` with `bearerToken` | `DefaultAzureCredential` (local dev) / `ManagedIdentityCredential` (production) |4344**Model discovery:**45- GitHub models: call `listModels()` on the SDK client46- Azure deployments: `az cognitiveservices account deployment list`4748Full BYOM config details: [Azure Model Configuration](azure-model-config.md).4950> โ ๏ธ **Warning:** `model` is **required** when using a provider โ SDK throws if missing.5152## Template Customization5354Read `AGENTS.md` FIRST โ it lists every source file with its purpose. Then:55561. Adapt routes โ update endpoints, system message, and tool definitions572. Customize the UI โ the template UI is just an example583. Keep template infra โ do NOT regenerate Dockerfile, Bicep, or `azure.yaml`594. If using multi-tool AI sessions, increase `proxy_read_timeout` in `nginx.conf.template` to 300s (default 60s causes 504)6061**Existing project:** See [Existing Project Integration](existing-project-integration.md) for adding Copilot SDK to your codebase.6263## Testing6465| Check | Command |66|-------|---------|67| Run locally | `azd app run` โ starts API + UI |68| Health check | `curl -s http://localhost:3000/health` |69| Test endpoint | `curl -s -X POST http://localhost:3000/api/<endpoint> -H "Content-Type: application/json" -d '{"input":"test"}'` |7071## Errors7273| Error | Fix |74|-------|-----|75| `docker info` fails | Install Docker Desktop and start it |76| `gh auth token` fails | Run `gh auth login` then `gh auth refresh --scopes copilot` |77| `ECONNREFUSED` on JSON-RPC | Set autoStart or start CLI manually |78| `Model not available` | Check model name; for BYOM verify provider config |79| Session hangs | Set a max turns limit or add a hook to break |80| `504 Gateway Timeout` | Increase `proxy_read_timeout` in `nginx.conf.template` to 300s |81