fix(web): honor Copilot model endpoints (#2382)

Route small-model requests through each Copilot model's advertised Messages, Responses, or Chat Completions endpoint.
This commit is contained in:
Jakub Syty
2026-07-23 22:48:18 +03:00
committed by GitHub
parent 38222d07c8
commit ddbb3c1db0
3 changed files with 328 additions and 18 deletions
@@ -37,9 +37,14 @@ other runtime API.
reported as `inputTruncated: true` in the response.
- `call.js` — wire formats and per-provider auth, replicating OpenCode's
plugin auth loaders:
- **GitHub Copilot**: OpenAI-compatible `/chat/completions` on
`https://api.githubcopilot.com` (or `copilot-api.<enterprise>`) with the
stored device-OAuth token as the bearer — no token exchange, no expiry.
- **GitHub Copilot**: fetches the requested model's authenticated `/models`
metadata from `https://api.githubcopilot.com` (or
`copilot-api.<enterprise>`) and honors its advertised endpoint, preferring
Anthropic-compatible `/v1/messages`, then OpenAI `/responses`, then
`/chat/completions`. Models without `supported_endpoints` retain the legacy
Chat Completions default; metadata, missing-model, and unsupported-endpoint
failures are surfaced instead of guessing. The stored device-OAuth token is
used as the bearer with no token exchange or expiry.
- **OpenAI OAuth (ChatGPT plan)**: streaming Responses API on
`https://chatgpt.com/backend-api/codex/responses` with
`ChatGPT-Account-Id`; expired tokens are refreshed against