A VS Code extension that exposes GitHub Copilot chat capabilities as a local API server for programmatic use.
- Exposes Copilot Chat models through a RESTful API
- Access to multiple AI models including GPT-4, Claude, and more
- Streaming and non-streaming response options
- Simple Python client for easy integration
- Install the VS Code extension
- Make sure GitHub Copilot Chat is installed and enabled in your VS Code
- Use the command palette (
Ctrl+Shift+P/Cmd+Shift+P) and select "Start Copilot API Server" - The server will run on a local port (default is 3000, or next available port)
- A status bar item will display the current port
The easiest way to use the API is with the provided Python client:
pip install crimson-copilot-init-clientfrom crimson.copilot_init_client.client import CopilotClient
# Initialize the client (connects to the local API server)
client = CopilotClient()
# List available models
models = client.list_models()
for model in models:
print(f"- {model['name']} ({model['vendor']}/{model['family']})")
# Get a completion response
client.chat("Write me a simple Python function to calculate factorial")
# Get a streaming response
for fragment in client.chat_stream("Write me a simple Python function to calculate factorial"):
print(fragment, end='', flush=True) # Print fragments as they arriveIf you prefer to use the API directly, the following endpoints are available:
Check if the API server is running.
List all available Copilot models.
Get a complete (non-streaming) response.
Request body:
{
"message": "Write a function to calculate factorial",
"history": [
{
"content": "I need help with Python",
"isUser": true
},
{
"content": "I'd be happy to help with Python. What do you need?",
"isUser": false
}
],
"vendor": "copilot",
"family": "gpt-4"
}Get a streaming response.
Request body: Same as /chat endpoint.
You can configure the extension to auto-start the API server when VS Code starts by adding the following to your settings.json:
{
"copilotApi.autoStart": true
}- VS Code 1.85.0 or higher
- GitHub Copilot Chat extension installed and enabled