Skip to main content

Copilot Proxy

CI Python 3.10+ License: MIT

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.

Copilot Proxy Demo

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

Metadata

Release files for copilot-lm-proxy 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for copilot-lm-proxy 0.2.0
File Size Uploaded Provenance
copilot_lm_proxy-0.2.0.tar.gz 22.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for copilot-lm-proxy 0.2.0
File Interpreter ABI Platform
copilot_lm_proxy-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.1 kB

Release files / copilot_lm_proxy-0.2.0.tar.gz

Download URL copilot_lm_proxy-0.2.0.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
37fbe289402f2150b86df5de00a41b790d897e52c2e0479ca911c0b6bf7822a5
BLAKE2b-256 checksum
How to use checksums
be70797c92903b4553f4b49b9f650eb55d682c62b58111cc1ee2845d8822a053
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 26, 2026.

Transparency log

Release files / copilot_lm_proxy-0.2.0-py3-none-any.whl

Download URL copilot_lm_proxy-0.2.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
284f9611cbce109ab36aa1e3cd5d0e66b006e53fbdefd95cae5253f356ece7c7
BLAKE2b-256 checksum
How to use checksums
447cc5ff8b0530e495c9aa99322117ba34f392d15a6851e1572b3a78962fa9c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 26, 2026.

Transparency log

Security for copilot-lm-proxy 0.2.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for copilot_lm_proxy-0.2.0.tar.gz

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 Mar 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page