Skip to content

Latest commit

 

History

History
78 lines (49 loc) · 1.65 KB

README.md

File metadata and controls

78 lines (49 loc) · 1.65 KB

Copilot Chat API (OpenAI Compatible)

Provides a simple HTTP API to interface with GitHub Copilot, including native GitHub authentication.

Forked from Copilot API to include chat endpoint.

Supports Cline

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.

cline

Dependencies

pip install -r requirements.txt

Run

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]

Usage

Chat Completions

Send a POST request to http://localhost:8080/v1/chat/completions with the following JSON body

Payload

{
  "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
}

Response

Stream

Streamed Responses

Non-Stream

Non-Streamed Responses

Code Completion

Send a POST request to http://localhost:8080/v1/code/completions with the following JSON body

Payload

{
  "prompt": "# hello world function\n\n",
  "language": "python"
}

Response

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.