开源项目 GitHub Trending 2026-07-16T12:01 正文 ok 881 words

GitHub 发布 Copilot SDK:将 Copilot Agent 集成到任意应用中

英文标题:🔥 github/copilot-sdk

GitHub 正式推出跨平台 Copilot SDK,支持 Python、TypeScript、Go、.NET、Java 和 Rust,可将 Copilot Agent 的规划、工具调用、文件编辑等能力嵌入应用。SDK 通过 JSON-RPC 与 Copilot CLI 通信,自动管理进程生命周期,并支持 BYOK(自带密钥)和多种认证方式。该项目已正式可用,方便开发者快速构建智能助手,无需自行实现编排层。
打开原文相关 3 · 机会 5
media55.9 KB media1.3 KB media1.3 KB media1.2 KB media3.5 KB media1.3 KB media1.3 KB media374.4 KB

中文

GitHub Copilot SDK

NPM Downloads PyPI - Downloads NuGet Downloads Go Reference crates.io Maven Central

为每一款应用注入 Agent 能力。

通过 GitHub Copilot SDK(支持 Python、TypeScript、Go、.NET、Java 和 Rust),将 Copilot 的 Agent 工作流嵌入你的应用。

GitHub Copilot SDK 暴露了 Copilot CLI 背后的同一引擎:一个经过生产验证的 agent 运行时,你可以通过编程方式调用。无需自己构建编排层——你只需定义 agent 行为,Copilot 负责处理规划、工具调用、文件编辑等。

请参阅各 SDK 的 README 了解安装、使用示例和 API 参考。

如需完整指引,请参阅 入门指南。

快速步骤:

  1. (可选)安装 Copilot CLI

对于 Node.js、Python 和 .NET SDK,Copilot CLI 会自动捆绑,无需单独安装。对于 Go、Java 和 Rust,请手动安装 CLI 或确保 copilot 在你的 PATH 中可用。Go 和 Rust 还提供了应用级 CLI 捆绑功能。

  1. 使用上述命令安装你偏好的 SDK。

  2. 查看 SDK README 了解使用示例和 API 文档。

所有 SDK 均通过 JSON-RPC 与 Copilot CLI 服务器通信:

你的应用
       ↓
  SDK 客户端
       ↓ JSON-RPC
  Copilot CLI(服务器模式)

SDK 会自动管理 CLI 进程的生命周期。你也可以连接到外部 CLI 服务器——有关在服务器模式下运行 CLI 的详细信息,请参阅入门指南。

使用 SDK 是否需要 GitHub Copilot 订阅?

是的,使用 GitHub Copilot SDK 需要 GitHub Copilot 订阅,除非你使用 BYOK(自带密钥)。通过 BYOK,你可以使用来自受支持 LLM 提供商的自有 API 密钥,无需 GitHub 身份验证即可使用 SDK。对于标准使用(非 BYOK),请参阅 GitHub Copilot 定价页面,其中包含有限额度的免费套餐。

SDK 使用的计费方式是怎样的?

GitHub Copilot SDK 的计费模式与 Copilot CLI 相同,每次提示都将计入你的使用配额。有关 Copilot 使用计费的更多信息,请参阅 GitHub Copilot 中的使用情况。

是否支持 BYOK(自带密钥)?

是的,GitHub Copilot SDK 支持 BYOK(自带密钥)。你可以配置 SDK 使用来自受支持 LLM 提供商(例如 OpenAI、Azure AI Foundry、Anthropic)的自有 API 密钥,通过这些提供商访问模型。请参阅 BYOK 文档 获取设置说明和示例。

注意: BYOK 仅使用基于密钥的身份验证。不支持 Microsoft Entra ID(Azure AD)、托管标识和第三方身份提供商。

支持哪些身份验证方法?

SDK 支持多种身份验证方法:

  • GitHub 登录用户——使用 copilot CLI 登录时存储的 OAuth 凭据
  • OAuth GitHub App——传递来自你的 GitHub OAuth 应用的用户令牌
  • 环境变量——COPILOT_GITHUB_TOKEN、GH_TOKEN、GITHUB_TOKEN
  • BYOK——使用你自己的 API 密钥(无需 GitHub 身份验证)

请参阅 身份验证文档 了解每种方法的详细信息。

是否需要单独安装 Copilot CLI?

不需要——对于 Node.js、Python 和 .NET SDK,Copilot CLI 已作为依赖项自动捆绑,无需单独安装。

对于 Go、Java 和 Rust SDK,CLI 不会默认捆绑。请手动安装 CLI 或确保 copilot 在你的 PATH 中可用。Go 和 Rust 还提供了应用级 CLI 捆绑功能。

高级:你可以覆盖 CLI 二进制文件或连接到外部服务器。请参阅各 SDK 的 README 了解语言特定的选项。

默认启用了哪些工具?

默认情况下,SDK 暴露 Copilot CLI 的一线工具,类似于以 --allow-all 运行 CLI。工具执行仍受各 SDK 权限处理程序的约束,因此应用可以批准、拒绝或自定义工具调用。你可以通过配置 SDK 客户端选项启用和禁用特定工具来定制工具可用性。有关工具配置的详细信息,请参阅各 SDK 文档;有关可用工具列表,请参阅 Copilot CLI 文档。

能否使用自定义 agent、技能或工具?

是的,GitHub Copilot SDK 允许你定义自定义 agent、技能和工具。你可以通过实现自己的逻辑并根据需要集成额外工具来扩展 agent 功能。更多详情请参阅你偏好的语言的 SDK 文档。

是否有用于加速开发的 Copilot 指令或 SDK 指南?

是的,请查看自定义指令和特定于 SDK 的指南:

支持哪些模型?

Copilot CLI 中可用的所有模型在 SDK 中均受支持。SDK 还暴露了一个方法,可返回可用模型,以便在运行时访问。

SDK 是否已可用于生产环境?

GitHub Copilot SDK 已正式发布,并遵循语义版本控制。请参阅 CHANGELOG.md 了解发布说明。

如何报告问题或请求功能?

请使用 GitHub Issues 页面报告缺陷或请求新功能。我们欢迎你的反馈,以帮助改进 SDK。

非官方、社区维护的 SDK

⚠️ 免责声明:这些是非官方、社区驱动的 SDK,不受 GitHub 支持。使用风险自负。

请参阅 CONTRIBUTING.md 了解贡献指南。

MIT

English / 原文

GitHub Copilot SDK

NPM Downloads PyPI - Downloads NuGet Downloads Go Reference crates.io Maven Central

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.

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.

See the individual SDK READMEs for installation, usage examples, and API reference.

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.

  1. Install your preferred SDK using the commands above.

  2. See the SDK README for usage examples and API documentation.

All SDKs communicate with the Copilot CLI server via JSON-RPC:

Your Application
       ↓
  SDK Client
       ↓ JSON-RPC
  Copilot 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.

Do I need a GitHub Copilot subscription to use the SDK?

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.

How does billing work for SDK usage?

Billing for the GitHub Copilot SDK is based on the same model as the Copilot CLI, with each prompt being counted towards your usage allowance. For more information on Copilot usage billing, see Usage in GitHub Copilot.

Does it support BYOK (Bring Your Own Key)?

Yes, the GitHub Copilot SDK supports BYOK (Bring Your Own Key). 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.

What authentication methods are supported?

The SDK supports multiple authentication methods:

  • GitHub signed-in user - Uses stored OAuth credentials from copilot CLI login
  • OAuth GitHub App - Pass user tokens from your GitHub OAuth app
  • Environment variables - COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN
  • BYOK - Use your own API keys (no GitHub auth required)

See the Authentication documentation for details on each method.

Do I need to install the Copilot CLI separately?

No — for Node.js, Python, and .NET SDKs, the Copilot CLI is bundled automatically as a dependency. You do not need to install it separately.

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. Go and Rust also expose application-level CLI bundling features.

Advanced: You can override the CLI binary or connect to an external server. See the individual SDK README for language-specific options.

What tools are enabled by default?

By default, the SDK exposes the Copilot CLI's first-party tools, similar to running the CLI with --allow-all. Tool execution is still governed by each SDK's permission handler, so applications can approve, deny, or customize tool calls. You can customize tool availability by configuring the SDK client options to enable and disable specific tools. Refer to the individual SDK documentation for details on tool configuration and to the Copilot CLI documentation for the list of available tools.

Can I use custom agents, skills or tools?

Yes, the GitHub Copilot SDK allows you to define custom agents, skills, and tools. You can extend the functionality of the agents by implementing your own logic and integrating additional tools as needed. Refer to the SDK documentation of your preferred language for more details.

Are there instructions or SDK guidance for Copilot to speed up development?

Yes, check out the custom instructions and SDK-specific guidance:

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.

Is the SDK production-ready?

The GitHub Copilot SDK is generally available and follows semantic versioning. See CHANGELOG.md for release notes.

How do I report issues or request features?

Please use the GitHub Issues page to report bugs or request new features. We welcome your feedback to help improve the SDK.

Unofficial, Community-maintained SDKs

⚠️ Disclaimer: These are unofficial, community-driven SDKs and they are not supported by GitHub. Use at your own risk.

See CONTRIBUTING.md for contribution guidelines.

MIT