This is a simple tool to use the GitHub Copilot API as a GPT API.
There are two ways to access the GitHub Copilot API.
gh-gpt loginPlease take this code "0000-0000" to authenticate at https://github.com/login/device.
Press 'y' to continue, or any other key to abort.
Waiting for authentication...Windows: ~\AppData\Local\github-copilot\hosts.json
Other: ~/.config/github-copilot/hosts.json
The file is created when you log in to Copilot in an IDE
- JetBrains (tested)
- VS Code
- ...
I have only tested ghu_ of Identifiable prefixes
GH_COPILOT_TOKEN=ghu_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXgh-gpt run "Who are you?"
# I am an artificial intelligence designed to assist with information and tasks. How can I help you today?Listening on http://127.0.0.1:8000
gh-gpt server --address :8000curl --location 'http://127.0.0.1:8000/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"}
]
}' | jq -r '.choices[0].message.content'
# I am an artificial intelligence designed to assist with information and tasks. How can I help you today?package main
import (
"context"
"os"
"github.com/wzshiming/gh-gpt/pkg/run"
)
func main() {
_ = run.RunStream(context.Background(), "Who are you?", os.Stdout)
// I am an artificial intelligence designed to assist with information and tasks. How can I help you today?
}