GitHub Copilot-compatible proxy for Z.AI GLM coding models
Project description
Copilot-Proxy
A proxy server that bridges GitHub Copilot Chat with GLM coding models by mimicking the Ollama API interface.
What it does
This proxy server intercepts requests from GitHub Copilot's Ollama provider and forwards them to a GLM coding plan backend. By implementing the Ollama API interface, it allows the GitHub Copilot VS Code extension to communicate with alternative language models seamlessly.
flowchart TD
A[GitHub Copilot Chat] -- Ollama API (localhost:11434) --> B[Copilot-Proxy Server]
B --> C[GLM Coding Plan Backend]
Quick Start
Prerequisites
- Python 3.10+
- UV for dependency management and packaging (install instructions)
- Z.AI Coding Plan access with a valid API key
Install from PyPI (recommended)
# Ensure uv is installed first
uv pip install copilot-proxy
# Or run without installing globally
uvx copilot-proxy --help
Run the proxy locally
# Quick one-liner using uvx
uvx copilot-proxy --host 127.0.0.1 --port 11434
# Or inside a synced project environment
uv sync
uv run copilot-proxy
The server listens on http://localhost:11434 by default (same port Ollama uses). Make sure Ollama itself is stopped to avoid port conflicts.
Configure credentials
New users (recommended):
# Interactive setup - runs automatically on first use
copilot-proxy
# Or manually run setup wizard
copilot-proxy config setup
Advanced users - Environment variables:
# PowerShell (current session only)
$env:ZAI_API_KEY = "your-zai-api-key"
# bash/zsh
export ZAI_API_KEY="your-zai-api-key"
You can optionally set a custom endpoint with ZAI_API_BASE_URL, though the default already targets the Coding Plan URL https://api.z.ai/api/coding/paas/v4.
Configuration Management:
# Set API key in persistent config
copilot-proxy config set-api-key your-zai-api-key
# View current configuration
copilot-proxy config get-api-key
# Set custom base URL
copilot-proxy config set-base-url https://your-custom-endpoint.com
# Show config file location
copilot-proxy config show-path
# Start proxy (uses saved config automatically)
copilot-proxy serve
# Set context length (controls Copilot context window size)
copilot-proxy config set-context-length 128000
# View current context length (default: 64000)
copilot-proxy config get-context-length
# Set default model
copilot-proxy config set-model GLM-4.7
# View current model
copilot-proxy config get-model
# Set temperature (0.0 = deterministic, 1.0 = creative)
copilot-proxy config set-temperature 0.1
# View current temperature
copilot-proxy config get-temperature
Priority Order: Config file > Environment variables > Default values
Configure GitHub Copilot in VS Code
- Open the GitHub Copilot Chat panel in VS Code
- Click on the current model name to view available models
- Click 'Manage Models...'
- Select 'Ollama' from the list of providers
- Choose your preferred model from the available GLM models
Available Models
The proxy advertises the GLM Coding Plan lineup so Copilot (or any Ollama-compatible client) can switch between them seamlessly:
| Model | Description | Concurrency |
|---|---|---|
GLM-4.7 |
Next-gen flagship with advanced "Vibe Coding" | 2 |
GLM-4-Plus |
High-throughput flagship variant | 20 |
GLM-4.6 |
Flagship coding model with top-tier reasoning | 3 |
GLM-4.5 |
Balanced performance for everyday coding | 10 |
GLM-4.5-Air |
Lightweight, faster response variant | 5 |
GLM-4.5-AirX |
Accelerated variant of the Air model | 5 |
GLM-4.5-Flash |
Ultra-fast, low-latency coding model | 2 |
GLM-4.6V |
Multimodal (Vision) flagship model | 10 |
GLM-4.6V-Flash |
Fast multimodal coding & analysis | 3 |
GLM-4.6V-FlashX |
Accelerated fast multimodal model | 3 |
GLM-4.5V |
Previous generation multimodal model | 10 |
AutoGLM-Phone-Multilingual |
Specialized mobile/agentic model | 5 |
GLM-4-32B-0414-128K |
Dense 32B parameter coding specialist | 15 |
Tip: These identifiers match the GLM Coding Plan catalog, so any OpenAI-compatible tool can use them by pointing to
https://api.z.ai/api/coding/paas/v4with your Coding Plan API key.
How it Works
The proxy server implements the Ollama API specification, allowing GitHub Copilot's Ollama provider to communicate with it. When Copilot sends requests to localhost:11434, the proxy intercepts these requests and forwards them to the GLM coding plan backend, then returns the responses in Ollama-compatible format.
Troubleshooting
Common Issues:
-
Port conflict errors
- Ensure Ollama is not running (both services use port 11434)
- Check that no other service is using port 11434
- On Windows, use:
netstat -ano | findstr :11434 - On Unix/Linux/Mac, use:
lsof -i :11434
-
Ollama provider not responding in Copilot Chat
- Verify the proxy server is running
- Check the terminal for any error messages
- Ensure the GLM backend is accessible
-
Models not appearing in VS Code
- Restart VS Code after starting the proxy server
- Make sure you've selected 'Ollama' as the provider in Copilot settings
- Check that the proxy server is responding at
http://localhost:11434
Developing locally
uv sync
uv run uvicorn copilot_proxy.app:app --reload --port 11434
Use uv run pytest (once tests are added) or uvx ruff check . for linting.
Releasing to PyPI with UV
-
Bump the version in
pyproject.toml. -
Build the distributions:
uv build
-
Check the metadata:
uvx twine check dist/*
-
Publish to TestPyPI (recommended before production):
uv publish --repository testpypi
-
Publish to PyPI:
uv publish
Both uv publish commands expect the relevant API token to be available in the UV_PUBLISH_TOKEN environment variable.
GitHub Actions trusted publisher
This repository includes .github/workflows/publish.yml, which builds and uploads releases automatically on GitHub tag releases. To enable it:
- Create a PyPI trusted publisher (pending or project-specific) pointing at:
- Project:
copilot-proxy - Owner:
modpotato - Repository:
copilot-proxy - Workflow:
publish.yml - Environment:
release
- Project:
- In GitHub, create the matching repository environment (
Settings → Environments → New environment → release). - Push a tag (e.g.
v0.1.0) to GitHub (git push origin v0.1.0). The workflow will build withuv, publish to PyPI via OIDC, and create the GitHub release automatically. - For dry runs, use the Run workflow button; the manual dispatch builds and validates without publishing or creating a release.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
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_proxy-0.1.4.tar.gz.
File metadata
- Download URL: copilot_proxy-0.1.4.tar.gz
- Upload date:
- Size: 14.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 |
748c15c6ace6c0279837e2f2f2fa13775837342b10960b79f73a2a87500dc665
|
|
| MD5 |
97958b4e0dd7385e0379c439f55eaeb4
|
|
| BLAKE2b-256 |
71ea3f68ffa01fa38a032eeef3192616af0d47f721f748eb6ee604b372e13a9d
|
Provenance
The following attestation bundles were made for copilot_proxy-0.1.4.tar.gz:
Publisher:
publish.yml on modpotato/copilot-proxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
copilot_proxy-0.1.4.tar.gz -
Subject digest:
748c15c6ace6c0279837e2f2f2fa13775837342b10960b79f73a2a87500dc665 - Sigstore transparency entry: 780182593
- Sigstore integration time:
-
Permalink:
modpotato/copilot-proxy@722537086d33c4f2617fed51dbaa852d7336988f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/modpotato
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@722537086d33c4f2617fed51dbaa852d7336988f -
Trigger Event:
push
-
Statement type:
File details
Details for the file copilot_proxy-0.1.4-py3-none-any.whl.
File metadata
- Download URL: copilot_proxy-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.6 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 |
a6cb5db580bc42ecce649a5babdf86bdda36521145e68cd4b341948ebfcb4643
|
|
| MD5 |
0629d375212e470da31a67f62c910fab
|
|
| BLAKE2b-256 |
15bf2f3ade26f821306a7b571c03a8b7cb6433d05f4eeefa0869a1f2b32c3f31
|
Provenance
The following attestation bundles were made for copilot_proxy-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on modpotato/copilot-proxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
copilot_proxy-0.1.4-py3-none-any.whl -
Subject digest:
a6cb5db580bc42ecce649a5babdf86bdda36521145e68cd4b341948ebfcb4643 - Sigstore transparency entry: 780182597
- Sigstore integration time:
-
Permalink:
modpotato/copilot-proxy@722537086d33c4f2617fed51dbaa852d7336988f -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/modpotato
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@722537086d33c4f2617fed51dbaa852d7336988f -
Trigger Event:
push
-
Statement type: