copilot-api lets existing AI tools talk to a local endpoint while the gateway
handles authentication, model discovery, protocol translation, streaming, tool
calls, provider routing, and usage accounting.
It began as an independent Rust reimplementation of
caozhiyuan/copilot-api and now
evolves independently. See NOTICE.md for attribution.
[!IMPORTANT]
This is unofficial community software. It is not affiliated with or endorsed
by GitHub, Microsoft, OpenAI, or Anthropic. Review the
disclaimer and use the project responsibly.
What you get
| Capability | What it unlocks |
|---|
| OpenAI compatibility | Chat Completions, Responses, compaction, models, embeddings, images, and a local Files API. |
| Anthropic compatibility | Messages, token counting, streaming, thinking blocks, tools, prompt caching, images, PDFs, and local file references. |
| Coding-agent support | Audited integration paths for Claude Code and Codex CLI, including their current headers, request shapes, and SSE lifecycles. |
| Backend choice | Use GitHub Copilot, Codex OAuth, Anthropic, OpenAI-compatible APIs, Responses-compatible APIs, or your own provider aliases. |
| Local control | API keys, admin routes, model mappings, token budgets, rate limits, load shedding, and provider-only mode. |
| Operational visibility | Readiness and version endpoints, Prometheus metrics, structured logs, diagnostics, and a built-in usage dashboard. |
| Simple distribution | Install from crates.io, download a release binary, build from source, or run the published container image. |
How it fits together
flowchart LR
A[Claude Code] --> G[copilot-api<br/>localhost:4141]
B[Codex CLI] --> G
C[OpenAI / Anthropic SDKs] --> G
D[Other compatible clients] --> G
G --> E[GitHub Copilot]
G --> F[Codex OAuth]
G --> H[Third-party providers]
G --> I[Local files]
G --> J[Usage + metrics]
Clients keep using familiar APIs. The gateway resolves the requested model,
selects the right upstream transport, translates the request and streaming
response, and preserves the client-facing protocol.
Quick start
1. Install
With Cargo:
cargo install copilot-api --locked
Or download a prebuilt binary from the
latest release.
Release assets are published for Linux x86-64, macOS Apple Silicon, and Windows
x86-64.
2. Start the gateway
copilot-api start
On first run, copilot-api starts GitHub's device-login flow, opens the
authorization page when possible, stores the token in your local app-data
directory, and loads the models available to your account.
The server listens on http://127.0.0.1:4141 by default.
3. Confirm it is ready
In another terminal:
curl -fsS http://127.0.0.1:4141/readyz
curl -fsS http://127.0.0.1:4141/v1/models
4. Send a request
Choose a model ID returned by /v1/models, replace MODEL_ID, and call the
OpenAI-compatible endpoint:
curl http://127.0.0.1:4141/v1/chat/completions \
-H "content-type: application/json" \
-d '{
"model": "MODEL_ID",
"messages": [
{"role": "user", "content": "Explain why Rust is useful for API gateways."}
]
}'
That is the complete local path: authenticate once, start one process, and point
your client at it.
Connect your client
The most common setup difference is whether the client expects /v1 in its base
URL: