llm-github-copilot
A plugin for LLM adding support for GitHub Copilot.
Installation
You can install this plugin using the LLM command-line tool:
llm install llm-github-copilot
Authentication
This plugin uses GitHub's device code authentication flow to obtain the initial access_token. This access_token is what is used to initiate and obtain an api_key that is used for communication with the GitHub Copilot API. This api_key is automatically obtained and refreshed as needed using the access_token. The access_token is obtained from the LLM key storage or via the environment variable GH_COPILOT_TOKEN or GITHUB_COPILOT_TOKEN
Free plan includes up to 2,000 completions and 50 chat requests per month.
Auth Command Help
$ llm github_copilot auth --help
Usage: llm github_copilot auth [OPTIONS] COMMAND [ARGS]...
Manage GitHub Copilot authentication.
Options:
--help Show this message and exit.
Commands:
login Authenticate with GitHub Copilot to generate a new access token.
logout Remove GitHub Copilot authentication credentials.
refresh Force refresh the GitHub Copilot API key.
status Check GitHub Copilot authentication status.
Authentication Login
When you run the login command, the plugin will:
- Start the GitHub device code authentication flow
- Provide you with a code and URL to visit
- Wait for you to authenticate on GitHub's website
- Generate and store an access token
- Fetch an API key using the access token
Example login output:
$ llm github_copilot auth login --help
Usage: llm github_copilot auth login [OPTIONS]
Authenticate with GitHub Copilot to generate a new access token.
Options:
-f, --force Force login even if already authenticated
--show-only Perform login but only display tokens, do not save them
--help Show this message and exit.
$ llm github_copilot auth login
Starting GitHub Copilot authentication to generate a new access token...
Please visit https://github.com/login/device and enter code XXXX-XXXX to authenticate GitHub Copilot.
Waiting for authorization... (attempt 1/12)
Authentication successful!
You can force a new login and obtain a new access_token even if already authenticated:
llm github_copilot auth login --force
You can also perform the login process and display the obtained access token and API key without saving them to the LLM keystore or the API key file. This is useful if you want to manually manage these tokens or use them in environment variables:
$ llm github_copilot auth login --show-only
GitHub Copilot: ✓ Authenticated
User: your_github_username
AccessToken: Valid
AccessToken: ghu_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
API Key: Valid, expires YYYY-MM-DD HH:MM:SS
API key: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
You can set GH_COPILOT_TOKEN or GITHUB_COPILOT_TOKEN to the token value above.
Note: These tokens have NOT been saved to the LLM keystore or API key file.
Authentication Status
You can check your authentication status with:
$ llm github_copilot auth status
GitHub Copilot: ✓ Authenticated
API Key: Valid, expires 2025-07-15 10:30:00
AccessToken: Valid, via keystore github_copilot_access_token
For more detailed information, use the verbose flag:
$ llm github_copilot auth status --verbose
GitHub Copilot: ✓ Authenticated
User: testuser
AccessToken: Valid, via keystore github_copilot_access_token
AccessToken: ghu_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
API Key: Valid, expires 2025-07-15 10:30:00
API key: abcdef1234567890abcdef1234567890
Usage
Once installed, you can use GitHub Copilot models with the llm command:
# Chat with GitHub Copilot
llm -m github_copilot/model-name "Write a Python function that calculates the Fibonacci sequence."
# Specify options like length
llm -m github_copilot/model-name "Tell me a joke" -o max_tokens 100
Options
The GitHub Copilot plugin supports the following options:
max_tokens: Maximum number of tokens to generate (default: 1024)temperature: Controls randomness in the output (default: 0.7)
Development
To develop this plugin:
# Clone the repository
git clone https://github.com/yourusername/llm-github-copilot.git
cd llm-github-copilot
# Install in development mode
llm install -e .
Testing
To run the tests:
# Install test dependencies
pip install -e ".[test]"
# Run tests
pytest
If you want to record new VCR cassettes for tests, set your API key:
export PYTEST_GITHUB_COPILOT_TOKEN=your_token_here
pytest --vcr-record=new_episodes
You can also run the tests in a containerized environment to avoid contamination from the environment (e.g. auth keys/files):
docker build -t llm-github-copilot-test .
docker run -it llm-github-copilot-test
Release files for llm-github-copilot 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llm_github_copilot-0.3.1.tar.gz | 18.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_github_copilot-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.4 kB
Release files / llm_github_copilot-0.3.1.tar.gz
| Download URL | llm_github_copilot-0.3.1.tar.gz |
|---|---|
| Size | 18.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
369974427ca535125c74ed42c51ab2c7ae06f544b461bf111ec53fd5d4ba5717
|
|
BLAKE2b-256 checksum How to use checksums |
0351c51ba3b807dec05450b73dfd7a253dc7387a579eecaca2c84e1fce1139e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 19, 2025.
Transparency logRelease files / llm_github_copilot-0.3.1-py3-none-any.whl
| Download URL | llm_github_copilot-0.3.1-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
963292916debb414827ac3645f4287d9579abcf72959e82186dd9ac2f460855b
|
|
BLAKE2b-256 checksum How to use checksums |
50b8058ae98d8096f46e31524036979b90e1a6b2effa1c44bbbb58409a16aaf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 19, 2025.
Transparency log