Skip to content

Commit f13f8f0

Browse files
committed
Add documentation on how things work
1 parent 596d14f commit f13f8f0

1 file changed

Lines changed: 137 additions & 3 deletions

File tree

readme.md

Lines changed: 137 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,144 @@
55
[![EULA](https://img.shields.io/badge/EULA-OSMF-blue?labelColor=black&color=C9FF30)](https://github.com/devlooped/oss/blob/main/osmfeula.txt)
66
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/devlooped/oss/blob/main/license.txt)
77

8-
<!-- include https://github.com/devlooped/.github/raw/main/osmf.md -->
8+
**ocp** is an OpenAI-compatible HTTP endpoint backed by the [GitHub Copilot SDK](https://github.com/github/copilot-sdk). It lets any client that speaks the OpenAI Chat Completions API — including [Grok](https://github.com/xai-org/grok-cli) — route requests through your GitHub Copilot subscription instead of a separate provider key.
9+
10+
Under the hood, ocp starts a local ASP.NET server and proxies chat to Copilot sessions. Model discovery comes from the SDK at runtime, so the available models match what your Copilot plan and CLI expose.
11+
912
<!-- #content -->
10-
## Usage
11-
*ocp*
13+
14+
## Prerequisites
15+
16+
- A [GitHub Copilot](https://github.com/features/copilot) subscription
17+
- Authenticated Copilot CLI credentials (`copilot` login, or `GH_TOKEN` / `GITHUB_TOKEN` / `COPILOT_GITHUB_TOKEN` in the environment)
18+
19+
## Install & Run
20+
21+
```bash
22+
dotnet tool install -g ocp
23+
ocp
24+
```
25+
26+
## Run without installing
27+
28+
```bash
29+
dnx -y ocp
30+
```
31+
32+
On startup, ocp prints the working directory, the models Copilot exposes, and the listen URL (default `http://localhost:11434`):
33+
34+
```
35+
ocp: using working directory: C:\Users\you\.ocp
36+
ocp: Copilot client started.
37+
ocp: models: gpt-5.5, gpt-5-mini, claude-sonnet-4.6, gpt-5.3-codex
38+
ocp: listening on http://localhost:11434 (OpenAI compatible)
39+
```
40+
41+
Options:
42+
43+
| Flag | Description |
44+
|------|-------------|
45+
| `--cwd <path>` | Copilot working directory (defaults to `~/.ocp`) |
46+
| `--help` | Show usage |
47+
48+
Install from source:
49+
50+
```bash
51+
dotnet pack src/ocp/ocp.csproj
52+
dotnet tool install -g --add-source ./bin ocp
53+
```
54+
55+
## API
56+
57+
| Method | Path | Description |
58+
|--------|------|-------------|
59+
| `GET` | `/v1/models` | OpenAI-compatible model list from Copilot |
60+
| `POST` | `/v1/chat/completions` | Chat completion (supports `stream: true`) |
61+
| `GET` | `/` | Health check |
62+
63+
Example:
64+
65+
```bash
66+
curl http://localhost:11434/v1/chat/completions \
67+
-H "Content-Type: application/json" \
68+
-d '{"model":"gpt-5.5","messages":[{"role":"user","content":"Hello"}]}'
69+
```
70+
71+
The `model` field must be a Copilot model id returned by `/v1/models`. ocp does not require an API key, though clients may send one anyway.
72+
73+
## Configure Grok (`[model.*]` in `config.toml`)
74+
75+
Add entries under `~/.grok/config.toml`. Each `[model.<picker-name>]` block tells Grok how to reach ocp; the `model` field is the Copilot model id sent in chat requests.
76+
77+
**1. Start ocp** and note the port from its startup log (11434 by default).
78+
79+
**2. Add a shared base URL** and one section per Copilot model you want in the picker:
80+
81+
```toml
82+
[models]
83+
default = "copilot-gpt-5.5"
84+
85+
# OpenAI models via Copilot
86+
[model.copilot-gpt-5.5]
87+
model = "gpt-5.5"
88+
base_url = "http://localhost:11434/v1"
89+
name = "GPT-5.5 (Copilot)"
90+
description = "GitHub Copilot — OpenAI GPT-5.5"
91+
context_window = 200000
92+
93+
[model.copilot-gpt-5-mini]
94+
model = "gpt-5-mini"
95+
base_url = "http://localhost:11434/v1"
96+
name = "GPT-5 mini (Copilot)"
97+
description = "Fast, lower-cost Copilot model"
98+
99+
[model.copilot-gpt-5.3-codex]
100+
model = "gpt-5.3-codex"
101+
base_url = "http://localhost:11434/v1"
102+
name = "GPT-5.3 Codex (Copilot)"
103+
description = "Code-focused Copilot model"
104+
105+
[model.copilot-gpt-5.4]
106+
model = "gpt-5.4"
107+
base_url = "http://localhost:11434/v1"
108+
name = "GPT-5.4 (Copilot)"
109+
110+
# Anthropic models via Copilot
111+
[model.copilot-claude-sonnet-4.6]
112+
model = "claude-sonnet-4.6"
113+
base_url = "http://localhost:11434/v1"
114+
name = "Claude Sonnet 4.6 (Copilot)"
115+
context_window = 200000
116+
117+
[model.copilot-claude-opus-4.6]
118+
model = "claude-opus-4.6"
119+
base_url = "http://localhost:11434/v1"
120+
name = "Claude Opus 4.6 (Copilot)"
121+
context_window = 200000
122+
123+
# Google models via Copilot
124+
[model.copilot-gemini-2.5-pro]
125+
model = "gemini-2.5-pro"
126+
base_url = "http://localhost:11434/v1"
127+
name = "Gemini 2.5 Pro (Copilot)"
128+
```
129+
130+
**3. Use the models in Grok:**
131+
132+
```bash
133+
grok models # lists custom entries alongside built-ins
134+
/model copilot-gpt-5.5 # switch in the TUI
135+
grok -p "refactor this" -m copilot-gpt-5.5
136+
```
137+
138+
### Notes
139+
140+
- **Model ids** — Use the exact ids from `ocp`'s startup line or `GET /v1/models`. Availability depends on your Copilot plan; see [GitHub's supported models](https://docs.github.com/en/copilot/reference/ai-models/supported-models).
141+
- **Section name vs model id**`[model.copilot-gpt-5.5]` is Grok's picker id; `model = "gpt-5.5"` is what ocp forwards to Copilot. They can differ, but keeping them aligned is easier to reason about.
142+
- **Port conflicts** — The default port 11434 is also used by Ollama. If both run locally, ocp tries successive ports automatically; update `base_url` to match the URL ocp prints.
143+
- **`api_backend`** — Omit it (defaults to `chat_completions`), which matches ocp's `/v1/chat/completions` endpoint.
144+
- **No API key** — ocp has no auth middleware. You do not need `api_key` or `env_key` unless another proxy sits in front.
145+
12146
<!-- #content -->
13147
---
14148
<!-- include https://github.com/devlooped/sponsors/raw/main/footer.md -->

0 commit comments

Comments
 (0)