Skip to content
This page was generated and translated with the assistance of AI. If you spot any inaccuracies, feel free to help improve it. Edit on GitHub

GitHub Copilot ​

Access GitHub Copilot Chat models via the Copilot API with automatic OAuth device-flow authentication and token management.

Prerequisites ​

  • A GitHub account with an active Copilot Individual, Copilot Business, or Copilot Enterprise subscription
  • Optionally, a GitHub personal access token (otherwise, interactive device-flow login is used)

Quick Setup ​

1. Authenticate ​

On first use, PRX will prompt you to authenticate via GitHub's device code flow:

GitHub Copilot authentication is required.
Visit: https://github.com/login/device
Code: XXXX-XXXX
Waiting for authorization...

Alternatively, provide a GitHub token directly:

bash
export GITHUB_TOKEN="ghp_..."

2. Configure ​

toml
[default]
provider = "copilot"
model = "gpt-4o"

3. Verify ​

bash
prx doctor models

Available Models ​

GitHub Copilot provides access to a curated set of models. The exact models available depend on your Copilot subscription tier:

ModelContextVisionTool UseNotes
gpt-4o128KYesYesDefault Copilot model
gpt-4o-mini128KYesYesFaster, cost-effective
claude-sonnet-4200KYesYesAvailable on Copilot Enterprise
o3-mini128KNoYesReasoning model

Model availability may vary based on your GitHub Copilot plan and GitHub's current model offerings.

Configuration Reference ​

FieldTypeDefaultDescription
api_keystringoptionalGitHub personal access token (ghp_... or gho_...)
modelstringgpt-4oDefault model to use

Features ​

Zero-Config Authentication ​

The Copilot provider implements the same OAuth device-code flow used by VS Code's Copilot extension:

  1. Device code request: PRX requests a device code from GitHub
  2. User authorization: You visit github.com/login/device and enter the code
  3. Token exchange: The GitHub OAuth token is exchanged for a short-lived Copilot API key
  4. Automatic caching: Tokens are cached to ~/.config/openprx/copilot/ with secure file permissions (0600)
  5. Auto-refresh: Expired Copilot API keys are automatically re-exchanged without re-authentication

Secure Token Storage ​

Tokens are stored with strict security:

  • Directory: ~/.config/openprx/copilot/ with 0700 permissions
  • Files: access-token and api-key.json with 0600 permissions
  • On non-Unix platforms, standard file creation is used

Dynamic API Endpoint ​

The Copilot API key response includes an endpoints.api field that specifies the actual API endpoint. PRX respects this, falling back to https://api.githubcopilot.com when no endpoint is specified.

Native Tool Calling ​

Tools are sent in OpenAI-compatible format via the Copilot Chat Completions API (/chat/completions). The provider supports tool_choice: "auto" for automatic tool selection.

Editor Headers ​

Requests include standard Copilot editor identification headers:

  • Editor-Version: vscode/1.85.1
  • Editor-Plugin-Version: copilot/1.155.0
  • User-Agent: GithubCopilot/1.155.0

Troubleshooting ​

"Failed to get Copilot API key (401/403)" ​

Your GitHub OAuth token may be expired or your Copilot subscription is inactive:

  • Ensure your GitHub account has an active Copilot subscription
  • PRX automatically clears the cached access token on 401/403 and will re-prompt for device-flow login

"Timed out waiting for GitHub authorization" ​

The device code flow has a 15-minute timeout. If it expires:

  • Run your PRX command again to get a new code
  • Make sure you visit the correct URL and enter the exact code shown

"GitHub device authorization expired" ​

The device code has expired. Simply retry your command to start a new authorization flow.

Models not available ​

The available models depend on your Copilot subscription tier:

  • Copilot Individual: GPT-4o, GPT-4o-mini
  • Copilot Business/Enterprise: May include additional models like Claude

Check your subscription at github.com/settings/copilot.

Rate limiting ​

GitHub Copilot has its own rate limits separate from OpenAI. If you encounter rate limiting, consider using fallback_providers in your PRX configuration to fall back to another provider.

Released under the Apache-2.0 License.