copilot-chat-completions is a script to provide good old OpenAI-like REST stateless chat user interface to LLMs
You unly need `server.py` here and follow instructions for installation of copilot and copilot-sdk below.
version: 0.2
Copilot Free quotes: 50 premium requests per month
“All permissions are granted” in create_new_session(client) function in server.py by default.
- GitHub Copilot CLI - proprietary binary executable
- https://github.com/github/copilot-sdk - MIT Licensed
- Python 3.14 should be with libffi-dev
- server.py - only required script
- test_* - tests that run with pytest
- requirements-dev.txt - dependencies for test_server.py
- patch-for-test-server.py - helping file for test_server.py
https://github.com/github/copilot-cli
Ways:
Way 1) from npm:
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
apt install nodejs -y
node -v
npm -v
npm install -g @github/copilotWay 2) from github: curl -fsSL https://gh.io/copilot-install | bash
https://gh.io/copilot-install is https://raw.githubusercontent.com/github/copilot-cli/main/install.sh
Way 3) from brew
sudo apt update
sudo apt install build-essential procps curl file git
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add Homebrew to your PATH
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install copilot-cligit clone --branch main --single-branch https://github.com/github/copilot-sdk.git
git tag
git checkout v1.0.8TARGET_FILE="copilot-sdk/python/pyproject.toml"
# Extract strings inside the dependencies list, strip quotes, and write to requirements.txt
grep -A 5 "dependencies\s*=" "$TARGET_FILE" | \
grep -o '"[^"]*"' | \
tr -d '"' > requirements.txt
echo "Extracted dependencies:"
cat requirements.txt
# Install dependencies using pip
pip3.14 install -r requirements.txtYou need fine-grainded token with permission to “copilot chat” and enabled Copilot in settings->Copilot->Features.
For single token use: COPILOT_GITHUB_TOKEN or GH_TOKEN or GITHUB_TOKEN.
Or you set multiple tokens with: TOKENS_POOL evironmental variable by separating them with (,): xx1,xx2,xx3.
TOKENS_POOL works like a loop over tokens until one will work.
To run:
export GITHUB_TOKEN="xxxxxxxx" # or TOKENS_POOL="xx1,xx2,xx3" # fine-grained token with copilot permission
export COPILOT_SKIP_CLI_DOWNLOAD=1
export COPILOT_CLI_PATH=/usr/bin/copilot # to find this use: $ whereis copilot
export PYTHONPATH="/path-to/copilot-sdk/python"
uvicorn server:app --host 127.0.0.1 --port 8000 --reloadTo Test:
curl --request POST \
--url http://localhost:8000/v1/chat/completions \
--header 'content-type: application/json' \
--data '{
"model": "gpt-4.1",
"messages": [
{"role": "user", "content": "Explain async functions in Python."}
]
}'