Replies: 1 comment
-
|
Consider case where Node is available, but a specific version for bundling. Also, consider NVM support needs. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
GitHub Copilot CLI SDK Auth & Bundling
Overview
The GitHub Copilot SDK provides a shim for Go, Python, TypeScript, and .NET that allows developers to create CLI sessions and access Copilot capabilities programmatically. This guide covers the authentication patterns, bundling strategies, and version management approaches for different integration scenarios.
Integration Scenarios
The SDK supports four primary integration patterns, each with distinct authentication and distribution requirements.
Scenario 1: Hobby and Personal Applications
This is the simplest integration pattern, designed for individual developers building personal projects on their local machine.
Use Case
A developer wants to add agentic AI capabilities to a side project, personal tool, or learning experiment. The app runs only on their machine and uses their personal GitHub Copilot subscription.
Authentication Flow
copilot auth loginuseLoggedInUser: trueSDK Configuration
Considerations
Scenario 2: Internal Enterprise Applications
For teams building internal tools where multiple users in an organization need to access the same application using their own GitHub identities.
Use Case
A development team creates an internal code review assistant or documentation generator. Team members sign in with their GitHub accounts, and each user's actions are attributed to their identity with their individual rate limits.
Authentication Flow
GitHub OAuth Setup
SDK Configuration
CLI Lockdown Mode
When deploying internal applications, you should ensure the CLI on the deployment machine does not accidentally use a different authenticated account. Configure the SDK to never fall back to logged-in users:
Considerations
Scenario 3: Production Backend Services
For production services that need to handle requests at scale, either passing through customer identities or using centralized API credentials.
Use Case
A SaaS platform integrates Copilot capabilities into their product. They need to either let customers use their own GitHub identities or manage API access centrally for all customers.
Option A: GitHub Token Pass-Through
In this model, your customers authenticate with GitHub, and their tokens are passed through your infrastructure to the SDK.
Option B: Bring Your Own Key (BYOK)
Use your own API credentials from OpenAI, Anthropic, or Azure AI Foundry. This provides enterprise-grade rate limits and centralized billing.
Comparison
Scenario 4: Desktop Applications for Customers
For software vendors distributing desktop applications to end customers who need embedded AI capabilities.
Use Case
A company builds a desktop IDE, code editor, or developer tool that includes Copilot-powered features. The application is distributed to customers who may or may not have GitHub accounts.
Option A: Embedded GitHub OAuth
Bundle a "Sign in with GitHub" flow directly in your desktop app. Customers authenticate and their tokens are used locally.
Option B: Token Exchange Service
For customers without GitHub accounts, build a backend token exchange service that provisions API credentials.
Considerations
Bundling and Distribution
The SDK requires the Copilot CLI to be available at runtime. There are two approaches: relying on a system-installed CLI or bundling the CLI directly with your application.
Approach Comparison
Language-Specific Bundling
Each supported language has different mechanisms for bundling the CLI binary with your application.
TypeScript / Node.js
For Node.js applications, bundle the CLI binary as a package asset and reference it at runtime.
Python
Python applications can bundle the CLI using package data or as part of a frozen application.
Go
Go applications can embed the CLI binary directly in the executable using go:embed.
.NET
.NET applications can bundle the CLI as an embedded resource or content file.
Version Management
The CLI and SDK are released frequently (daily builds for bug fixes and improvements). Managing version compatibility is critical for production applications.
Compatibility Model
The SDK specifies a minimum supported CLI version. Using a CLI version below this minimum may result in missing features, API incompatibilities, or runtime errors.
Version Management by Scenario
Handling Infrastructure Breaking Changes
Occasionally, backend infrastructure changes may require coordinated CLI/SDK updates beyond normal version compatibility. When this occurs:
Recommendations
Rate Limit Considerations
Quick Reference: Choosing Your Integration Pattern
Use this decision guide to select the appropriate integration pattern:
useLoggedInUser: trueFor additional support, consult the SDK API reference documentation or open an issue on the GitHub repository.
Beta Was this translation helpful? Give feedback.
All reactions