Skip to content

Commit f38b56f

Browse files
committed
docs: Update README with API endpoints, usage tips, and descriptions
1 parent 43dc70c commit f38b56f

File tree

1 file changed

+39
-26
lines changed

1 file changed

+39
-26
lines changed

README.md

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copilot API
1+
# Copilot API Proxy
22

33
> [!WARNING]
44
> This is a reverse-engineered proxy of GitHub Copilot API. It is not supported by GitHub, and may break unexpectedly. Use at your own risk.
@@ -7,7 +7,7 @@
77

88
## Project Overview
99

10-
A wrapper around GitHub Copilot API to make it OpenAI compatible, making it usable for other tools like AI assistants, local interfaces, and development utilities.
10+
A reverse-engineered proxy for the GitHub Copilot API that exposes it as an OpenAI and Anthropic compatible service. This allows you to use GitHub Copilot with any tool that supports the OpenAI Chat Completions API or the Anthropic Messages API.
1111

1212
## Demo
1313

@@ -16,7 +16,7 @@ https://github.com/user-attachments/assets/7654b383-669d-4eb9-b23c-06d7aefee8c5
1616
## Prerequisites
1717

1818
- Bun (>= 1.2.x)
19-
- GitHub account with Copilot subscription (Individual or Business)
19+
- GitHub account with Copilot subscription (individual, business, or enterprise)
2020

2121
## Installation
2222

@@ -64,7 +64,7 @@ npx copilot-api@latest auth
6464

6565
Copilot API now uses a subcommand structure with two main commands:
6666

67-
- `start`: Start the Copilot API server (default command). This command will also handle authentication if needed.
67+
- `start`: Start the Copilot API server. This command will also handle authentication if needed.
6868
- `auth`: Run GitHub authentication flow without starting the server. This is typically used if you need to generate a token for use with the `--github-token` option, especially in non-interactive environments.
6969

7070
## Command Line Options
@@ -73,22 +73,45 @@ Copilot API now uses a subcommand structure with two main commands:
7373

7474
The following command line options are available for the `start` command:
7575

76-
| Option | Description | Default | Alias |
77-
| -------------- | ----------------------------------------------------------------------------- | ------- | ----- |
78-
| --port | Port to listen on | 4141 | -p |
79-
| --verbose | Enable verbose logging | false | -v |
76+
| Option | Description | Default | Alias |
77+
| -------------- | ----------------------------------------------------------------------------- | ---------- | ----- |
78+
| --port | Port to listen on | 4141 | -p |
79+
| --verbose | Enable verbose logging | false | -v |
8080
| --account-type | Account type to use (individual, business, enterprise) | individual | -a |
81-
| --manual | Enable manual request approval | false | none |
82-
| --rate-limit | Rate limit in seconds between requests | none | -r |
83-
| --wait | Wait instead of error when rate limit is hit | false | -w |
84-
| --github-token | Provide GitHub token directly (must be generated using the `auth` subcommand) | none | -g |
81+
| --manual | Enable manual request approval | false | none |
82+
| --rate-limit | Rate limit in seconds between requests | none | -r |
83+
| --wait | Wait instead of error when rate limit is hit | false | -w |
84+
| --github-token | Provide GitHub token directly (must be generated using the `auth` subcommand) | none | -g |
8585

8686
### Auth Command Options
8787

8888
| Option | Description | Default | Alias |
8989
| --------- | ---------------------- | ------- | ----- |
9090
| --verbose | Enable verbose logging | false | -v |
9191

92+
## API Endpoints
93+
94+
The server exposes several endpoints to interact with the Copilot API. It provides OpenAI-compatible endpoints and now also includes support for Anthropic-compatible endpoints, allowing for greater flexibility with different tools and services.
95+
96+
### OpenAI Compatible Endpoints
97+
98+
These endpoints mimic the OpenAI API structure.
99+
100+
| Endpoint | Method | Description |
101+
| --------------------------- | ------ | --------------------------------------------------------- |
102+
| `POST /v1/chat/completions` | `POST` | Creates a model response for the given chat conversation. |
103+
| `GET /v1/models` | `GET` | Lists the currently available models. |
104+
| `POST /v1/embeddings` | `POST` | Creates an embedding vector representing the input text. |
105+
106+
### Anthropic Compatible Endpoints
107+
108+
These endpoints are designed to be compatible with the Anthropic Messages API.
109+
110+
| Endpoint | Method | Description |
111+
| -------------------------------- | ------ | ------------------------------------------------------------ |
112+
| `POST /v1/messages` | `POST` | Creates a model response for a given conversation. |
113+
| `POST /v1/messages/count_tokens` | `POST` | Calculates the number of tokens for a given set of messages. |
114+
92115
## Example Usage
93116

94117
Using with npx:
@@ -143,18 +166,8 @@ bun run start
143166

144167
## Usage Tips
145168

146-
- Consider using free models (e.g., Gemini, Mistral, Openrouter) as the `weak-model`
147-
- Use architect mode sparingly
148-
- Disable `yes-always` in your aider configuration
149-
- Enable the `--manual` flag to review and approve each request before processing
169+
- To avoid hitting GitHub Copilot's rate limits, you can use the following flags:
170+
- `--manual`: Enables manual approval for each request, giving you full control over when requests are sent.
171+
- `--rate-limit <seconds>`: Enforces a minimum time interval between requests. For example, `copilot-api start --rate-limit 30` will ensure there's at least a 30-second gap between requests.
172+
- `--wait`: Use this with `--rate-limit`. It makes the server wait for the cooldown period to end instead of rejecting the request with an error. This is useful for clients that don't automatically retry on rate limit errors.
150173
- If you have a GitHub business or enterprise plan account with Copilot, use the `--account-type` flag (e.g., `--account-type business`). See the [official documentation](https://docs.github.com/en/enterprise-cloud@latest/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-access-to-github-copilot-in-your-organization/managing-github-copilot-access-to-your-organizations-network#configuring-copilot-subscription-based-network-routing-for-your-enterprise-or-organization) for more details.
151-
152-
### Manual Request Approval
153-
154-
When using the `--manual` flag, the server will prompt you to approve each incoming request:
155-
156-
```
157-
? Accept incoming request? > (y/N)
158-
```
159-
160-
This helps you control usage and monitor requests in real-time.

0 commit comments

Comments
 (0)