Python client for accessing GitHub Copilot LLMs via local proxy
Project description
Copilot Proxy
Access GitHub Copilot's LLM models (GPT-4.1, GPT-5.x, Claude, Gemini, and more) from any Python script via a local HTTP server. Works with the standard OpenAI Python client. Zero dependencies.
Prerequisites
- VS Code with the GitHub Copilot extension (requires a Copilot subscription)
- Node.js (v18+) — for building the VS Code extension
- Python 3.10+
Quick Start
One-command install
git clone https://github.com/hsaghir/copilot-proxy.git
cd copilot-proxy
make install
This builds the VS Code extension, installs it, and installs the Python client. Then reload VS Code (Ctrl+Shift+P → "Reload Window").
Manual install (without Make)
1. Install the VS Code extension:
cd vscode-extension
npm install
npm run compile
npx @vscode/vsce package --allow-missing-repository
code --install-extension copilot-proxy.vsix
Reload VS Code. The proxy starts automatically on http://127.0.0.1:19823.
2. Install the Python client:
pip install -e .
# or with uv:
uv pip install -e .
Verify it works
from copilot_proxy import ask
print(ask("Hello!"))
Usage
Python Client (zero dependencies)
from copilot_proxy import ask, chat, list_models
# Simple question (uses default model)
response = ask("Explain neural networks")
# Use a specific model
response = ask("Explain quantum computing", model="gpt-4.1")
# Multi-turn conversation
response = chat([
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is 2+2?"}
], model="claude-sonnet-4")
# List all available models
for m in list_models():
print(f" {m['id']} ({m['vendor']})")
OpenAI Python Client (drop-in compatible)
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:19823/v1", api_key="dummy")
response = client.chat.completions.create(
model="gpt-4.1",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
# Streaming
for chunk in client.chat.completions.create(
model="gpt-4.1",
messages=[{"role": "user", "content": "Tell me a joke"}],
stream=True
):
print(chunk.choices[0].delta.content or "", end="")
HTTP API (curl)
# List models
curl http://127.0.0.1:19823/v1/models
# Chat completion
curl http://127.0.0.1:19823/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4.1", "messages": [{"role": "user", "content": "Hello!"}]}'
Available Models
With a GitHub Copilot subscription you get access to many models. Run list_models() or curl http://127.0.0.1:19823/v1/models to see all. Common ones:
| Model | ID |
|---|---|
| GPT-4.1 | gpt-4.1 |
| GPT-5.1 | gpt-5.1 |
| GPT-5.4 | gpt-5.4 |
| GPT-4o | gpt-4o |
| Claude Sonnet 4.6 | claude-sonnet-4.6 |
| Claude Opus 4.6 | claude-opus-4.6 |
| Claude Haiku 4.5 | claude-haiku-4.5 |
| Gemini 2.5 Pro | gemini-2.5-pro |
| Gemini 3 Pro | gemini-3-pro-preview |
Structured Output with Pydantic
pip install copilot-lm-proxy[pydantic]
from pydantic import BaseModel
from copilot_proxy import ask
import json
class MovieReview(BaseModel):
title: str
rating: float
summary: str
schema = MovieReview.model_json_schema()
prompt = f"Review Inception. Return JSON matching this schema: {json.dumps(schema)}"
response = ask(prompt, model="gpt-4.1")
review = MovieReview.model_validate_json(response)
Configuration
The proxy uses sensible defaults but everything is configurable:
| Setting | Default | How to change |
|---|---|---|
| Proxy port | 19823 |
VS Code: Settings → Copilot Proxy → Port |
| Python base URL | http://127.0.0.1:19823 |
Env var COPILOT_PROXY_URL or CopilotClient(base_url=...) |
Error Handling
from copilot_proxy import ask, ProxyConnectionError, ModelNotFoundError
try:
result = ask("Hello", model="gpt-4.1")
except ProxyConnectionError:
print("Proxy not running — reload VS Code")
except ModelNotFoundError:
print("Model not available")
Troubleshooting
| Problem | Fix |
|---|---|
Connection refused on port 19823 |
Reload VS Code. Check Output → "Copilot Proxy" panel. |
EADDRINUSE: address already in use |
lsof -ti:19823 | xargs kill -9 then reload VS Code. |
| Empty responses | Make sure you're signed into GitHub Copilot in VS Code. |
No models available |
Open Copilot Chat in VS Code first to initialize the session. |
Model returns empty but gpt-4o works |
Try specifying a different model — not all models are available in all regions. |
Development
pip install -e ".[dev]" # install with test deps
pytest tests/test_client.py -v # unit tests (no proxy needed)
pytest -v # all tests (proxy must be running)
See CONTRIBUTING.md for details.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file copilot_lm_proxy-0.2.0.tar.gz.
File metadata
- Download URL: copilot_lm_proxy-0.2.0.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37fbe289402f2150b86df5de00a41b790d897e52c2e0479ca911c0b6bf7822a5
|
|
| MD5 |
c10de5e1564da7d2566ad713e055cbb2
|
|
| BLAKE2b-256 |
be70797c92903b4553f4b49b9f650eb55d682c62b58111cc1ee2845d8822a053
|
Provenance
The following attestation bundles were made for copilot_lm_proxy-0.2.0.tar.gz:
Publisher:
publish.yml on hsaghir/copilot-proxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
copilot_lm_proxy-0.2.0.tar.gz -
Subject digest:
37fbe289402f2150b86df5de00a41b790d897e52c2e0479ca911c0b6bf7822a5 - Sigstore transparency entry: 1185096786
- Sigstore integration time:
-
Permalink:
hsaghir/copilot-proxy@d792e52752aa62ddf13f198dfceba2e851bea52b -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/hsaghir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d792e52752aa62ddf13f198dfceba2e851bea52b -
Trigger Event:
release
-
Statement type:
File details
Details for the file copilot_lm_proxy-0.2.0-py3-none-any.whl.
File metadata
- Download URL: copilot_lm_proxy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
284f9611cbce109ab36aa1e3cd5d0e66b006e53fbdefd95cae5253f356ece7c7
|
|
| MD5 |
93df7b0a8883d5a99b58591f84b1e552
|
|
| BLAKE2b-256 |
447cc5ff8b0530e495c9aa99322117ba34f392d15a6851e1572b3a78962fa9c2
|
Provenance
The following attestation bundles were made for copilot_lm_proxy-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on hsaghir/copilot-proxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
copilot_lm_proxy-0.2.0-py3-none-any.whl -
Subject digest:
284f9611cbce109ab36aa1e3cd5d0e66b006e53fbdefd95cae5253f356ece7c7 - Sigstore transparency entry: 1185096788
- Sigstore integration time:
-
Permalink:
hsaghir/copilot-proxy@d792e52752aa62ddf13f198dfceba2e851bea52b -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/hsaghir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d792e52752aa62ddf13f198dfceba2e851bea52b -
Trigger Event:
release
-
Statement type: