Skip to content

Latest commit

 

History

History
59 lines (39 loc) · 1.19 KB

File metadata and controls

59 lines (39 loc) · 1.19 KB

GithubCopilotAI

Using GitHub Copilot API like OpenAI API.

For learning and research purposes only. There is no guarantee of availability. Don't file issues.

Installation

pnpm add github-copilot-ai

Usage

Just like OpenAI API.

Read more at OpenAI documentation.

import { GithubCopilotAI } from 'github-copilot-ai'

const client = new GithubCopilotAI({
  apiKey: 'YOUR_COPILOT_OAUTH_TOKEN',
})

const response = await client.chat.completions.create({
  model: 'claude-sonnet-4',
  messages: [
    {
      role: 'user',
      content: 'Who are you?',
    },
  ],
})

How to get Copilot OAuth Token

We create a simple script to get GitHub Auth Token.

pnpm run oauth

Follow the instructions in the script to get your GitHub Auth Token.

Refer to the source code for more details, if you want to implement it elsewhere or in another language.

Python version?

https://gist.github.com/dragon-fish/86432fc4baa69875ce1013e0c8dd472c

I'm not good at Python. This entire script is converted from the TypeScript version by copilot itself. WOW, NTR


MIT License

Copyright © 2025 @dragon-fish