github / copilot-sdk

GitHub Copilot SDK

GitHub Copilot CLI SDKs Agents for every app. Embed Copilot’s agentic workflows in your application with the GitHub Copilot SDK for Python, TypeScript, Go, .NET, Java, and Rust. GitHub Copilot CLI SDK:适用于每个应用的智能体。通过适用于 Python、TypeScript、Go、.NET、Java 和 Rust 的 GitHub Copilot SDK,将 Copilot 的智能体工作流嵌入到您的应用程序中。

The GitHub Copilot SDK exposes the same engine behind Copilot CLI: a production-tested agent runtime you can invoke programmatically. No need to build your own orchestration—you define agent behavior, Copilot handles planning, tool invocation, file edits, and more. GitHub Copilot SDK 提供了与 Copilot CLI 相同的底层引擎:一个经过生产环境验证、可通过编程调用的智能体运行时。无需自行构建编排逻辑——您只需定义智能体行为,Copilot 即可处理规划、工具调用、文件编辑等任务。

Available SDKs (可用 SDK)

SDKLocationCookbookInstallation
Node.js / TypeScriptnodejs/Cookbooknpm install @github/copilot-sdk
Pythonpython/Cookbookpip install github-copilot-sdk
Gogo/Cookbookgo get github.com/github/copilot-sdk/go
.NETdotnet/Cookbookdotnet add package GitHub.Copilot.SDK
Rustrust/cargo add github-copilot-sdk
Javajava/CookbookMaven coordinates com.github:copilot-sdk-java

See instructions for Maven and Gradle. See the individual SDK READMEs for installation, usage examples, and API reference. 请参阅 Maven 和 Gradle 的说明。有关安装、使用示例和 API 参考,请参阅各 SDK 的 README 文件。

Getting Started (入门指南)

For a complete walkthrough, see the Getting Started Guide. Quick steps: 如需完整演练,请参阅《入门指南》。快速步骤如下:

  1. (Optional) Install the Copilot CLI: For Node.js, Python, and .NET SDKs, the Copilot CLI is bundled automatically and no separate installation is required. For Go, Java, and Rust, install the CLI manually or ensure copilot is available in your PATH. Go and Rust also expose application-level CLI bundling features. (可选) 安装 Copilot CLI: 对于 Node.js、Python 和 .NET SDK,Copilot CLI 会自动捆绑,无需单独安装。对于 Go、Java 和 Rust,请手动安装 CLI 或确保 copilot 在您的 PATH 环境变量中。Go 和 Rust 还提供了应用级的 CLI 捆绑功能。
  2. Install your preferred SDK using the commands above. 使用上述命令安装您首选的 SDK。
  3. See the SDK README for usage examples and API documentation. 查看 SDK 的 README 以获取使用示例和 API 文档。

Architecture (架构)

All SDKs communicate with the Copilot CLI server via JSON-RPC: 所有 SDK 均通过 JSON-RPC 与 Copilot CLI 服务器通信:

Your ApplicationSDK ClientJSON-RPCCopilot CLI (server mode)

The SDK manages the CLI process lifecycle automatically. You can also connect to an external CLI server—see the Getting Started Guide for details on running the CLI in server mode. SDK 会自动管理 CLI 进程生命周期。您也可以连接到外部 CLI 服务器——有关以服务器模式运行 CLI 的详细信息,请参阅《入门指南》。


FAQ (常见问题解答)

Do I need a GitHub Copilot subscription to use the SDK? 使用 SDK 是否需要 GitHub Copilot 订阅? Yes, a GitHub Copilot subscription is required to use the GitHub Copilot SDK, unless you are using BYOK (Bring Your Own Key). With BYOK, you can use the SDK without GitHub authentication by configuring your own API keys from supported LLM providers. For standard usage (non-BYOK), refer to the GitHub Copilot pricing page, which includes a free tier with limited usage. 是的,除非使用 BYOK(自带密钥),否则使用 GitHub Copilot SDK 需要 GitHub Copilot 订阅。通过 BYOK,您可以配置受支持 LLM 提供商的 API 密钥,从而无需 GitHub 身份验证即可使用 SDK。对于标准用法(非 BYOK),请参阅 GitHub Copilot 定价页面,其中包含有限额的免费层级。

How does billing work for SDK usage? SDK 使用如何计费? Billing for the GitHub Copilot SDK is based on the same model as the Copilot CLI, with each prompt being counted towards your premium request quota. For more information on premium requests, see Requests in GitHub Copilot. GitHub Copilot SDK 的计费模式与 Copilot CLI 相同,每个提示词都会计入您的高级请求配额。有关高级请求的更多信息,请参阅 GitHub Copilot 中的请求说明。

Does it support BYOK (Bring Your Own Key)? 它支持 BYOK(自带密钥)吗? Yes, the GitHub Copilot SDK supports BYOK. You can configure the SDK to use your own API keys from supported LLM providers (e.g. OpenAI, Azure AI Foundry, Anthropic) to access models through those providers. See the BYOK documentation for setup instructions and examples. Note: BYOK uses key-based authentication only. Microsoft Entra ID (Azure AD), managed identities, and third-party identity providers are not supported. 是的,GitHub Copilot SDK 支持 BYOK。您可以配置 SDK 使用来自受支持 LLM 提供商(如 OpenAI、Azure AI Foundry、Anthropic)的 API 密钥,通过这些提供商访问模型。有关设置说明和示例,请参阅 BYOK 文档。注意:BYOK 仅支持基于密钥的身份验证。不支持 Microsoft Entra ID (Azure AD)、托管标识和第三方身份提供商。

What authentication methods are supported? 支持哪些身份验证方法? The SDK supports multiple authentication methods: GitHub signed-in user, OAuth GitHub App, Environment variables (COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN), and BYOK. See the Authentication documentation for details. SDK 支持多种身份验证方法:GitHub 已登录用户、OAuth GitHub App、环境变量(COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN)以及 BYOK。有关每种方法的详细信息,请参阅身份验证文档。

Do I need to install the Copilot CLI separately? 我需要单独安装 Copilot CLI 吗? No — for Node.js, Python, and .NET SDKs, the Copilot CLI is bundled automatically. For Go, Java, and Rust SDKs, the CLI is not bundled by default. Install the CLI manually or ensure copilot is available in your PATH. 不需要——对于 Node.js、Python 和 .NET SDK,Copilot CLI 会自动捆绑。对于 Go、Java 和 Rust SDK,默认不捆绑 CLI。请手动安装 CLI 或确保 copilot 在您的 PATH 中。

What tools are enabled by default? 默认启用哪些工具? By default, the SDK exposes the Copilot CLI’s first-party tools. Tool execution is governed by each SDK’s permission handler, so applications can approve, deny, or customize tool calls. 默认情况下,SDK 会公开 Copilot CLI 的第一方工具。工具执行受各 SDK 的权限处理程序管理,因此应用程序可以批准、拒绝或自定义工具调用。

Can I use custom agents, skills or tools? 我可以使用自定义智能体、技能或工具吗? Yes, the GitHub Copilot SDK allows you to define custom agents, skills, and tools. Refer to the SDK documentation of your preferred language for more details. 是的,GitHub Copilot SDK 允许您定义自定义智能体、技能和工具。有关详细信息,请参阅您所选语言的 SDK 文档。

Are there instructions or SDK guidance for Copilot to speed up development? 是否有关于 Copilot 的说明或 SDK 指导来加速开发? Yes, check out the custom instructions and SDK-specific guidance for Node.js, Python, .NET, Go, Rust, and Java. 是的,请查看针对 Node.js、Python、.NET、Go、Rust 和 Java 的自定义说明和 SDK 特定指导。

What models are supported? 支持哪些模型? All models available via Copilot CLI are supported in the SDK. The SDK also exposes a method which will return the models available so they can be accessed at runtime. SDK 支持通过 Copilot CLI 提供的所有模型。SDK 还提供了一个方法,用于返回可用模型,以便在运行时进行访问。

Is the SDK production-ready? SDK 是否已准备好用于生产环境? The GitHub Copilot SDK is generally available and follows semantic versioning. See CHANGELOG.md for release notes. GitHub Copilot SDK 已正式发布(GA),并遵循语义化版本控制。请参阅 CHANGELOG.md 获取发行说明。

How do I report issues or request features? 如何报告问题或请求功能? Please use the GitHub Issues page to report bugs or request new features. 请使用 GitHub Issues 页面报告错误或请求新功能。