Provides a simple HTTP API to interface with GitHub Copilot, including native GitHub authentication.
Forked from Copilot API to include chat endpoint.
Set your API provider to OpenAI Compatible and the Base URL to this server.
Your API key can be anything. Change your model to any model supported by Copilot.
pip install -r requirements.txt
Run the local server with this command or use one of the scripts windows.bat
or mac-linux.sh
scripts to setup and run in a virtual environment.
python api.py [port]
Send a POST request to http://localhost:8080/v1/chat/completions
with the following JSON body
{
"model": "claude-3.5-sonnet",
"messages": [{ "role": "user", "content": "Hello, how are you?" }],
"temperature": 0.7, // default: 1.0
"max_tokens": 1000 // default: 9999999
"stream": true, // default: false
}
Send a POST request to http://localhost:8080/v1/code/completions
with the following JSON body
{
"prompt": "# hello world function\n\n",
"language": "python"
}
The response will be a plain text string containing the generated code.
def hello_world():
In order to build a complete code snippet, iteratively append the generated code to the prompt and send it back to the API until the response is empty.