| name | codex-github-copilot |
|---|---|
| description | Configure the OpenAI Codex CLI to run inference on a GitHub Copilot subscription DIRECTLY (no proxy) — requests go straight to api.githubcopilot.com, authenticated with a pinned `gh auth token`. Includes native web search with GPT-5.6 Sol. Use when setting up Codex on Copilot credits/models, or fixing a 401 "input item does not belong to this connection". |
Point the OpenAI Codex CLI at your GitHub Copilot subscription so it uses your
Copilot credits/models — no OpenAI API key, and no local proxy. Codex talks straight
to https://api.githubcopilot.com, authenticating with a GitHub CLI token supplied by a
command-backed provider (gh auth token).
An earlier version of this gist used a local
copilot-apiproxy onlocalhost:4141. That still works, but the direct method below is simpler — no background daemon and no LaunchAgent to keep alive.
codex ──Responses API──▶ https://api.githubcopilot.com
Authorization: Bearer $(gh auth token --user <copilot-account>)
- Codex's
[model_providers.*.auth]runsgh auth tokenon every request and uses the result as the bearer token — nothing is stored in the config file. - Your GitHub CLI (
gh) must be logged into the account that holds the Copilot subscription.
Codex 0.144+ only speaks the Responses API (wire_api = "chat" was removed). Copilot
serves each model on exactly one API surface, so from Codex you can reach only the
responses-capable models:
| Reachable from Codex (responses) | NOT reachable |
|---|---|
all GPT-5.x: gpt-5.3-codex, gpt-5.4(/-mini), gpt-5.5, gpt-5.6-luna/sol/terra, gpt-5-mini; plus mai-code-1-flash-picker |
Gemini (Copilot serves it chat-only) and Claude (Anthropic /v1/messages only) |
Check your live list:
curl -s -H "Authorization: Bearer $(gh auth token)" \
https://api.githubcopilot.com/models | jq -r '.data[].id'- macOS/Linux with the Codex CLI (
codex --version) and GitHub CLI (gh --version). - An active GitHub Copilot subscription on a
github.comaccount. ghlogged into that account:gh auth login --hostname github.com.
./setup.sh <your-copilot-github-username>The script is idempotent. It verifies codex/gh, checks that the account's token reaches
Copilot, writes the github-copilot-direct provider into ~/.codex/config.toml (pinned to
that account — see below), and runs a smoke test. Prefer to do it by hand? Merge
config-snippet.toml into ~/.codex/config.toml.
gh auth token with no --user returns whichever account is currently active for
that host. If you have more than one gh account (e.g. work + personal), the active one
can flip — and then Codex authenticates as the wrong identity. Symptom:
401 Unauthorized: input item does not belong to this connection
url: https://api.githubcopilot.com/responses
This is not a token/subscription failure (every valid GitHub token returns 200 on
/models). It's the Responses API rejecting a previous_response_id that was created
under a different connection — i.e. the account changed mid-session.
Fix: pin the provider's auth command to the exact account so it's deterministic no matter which account is "active" for git:
[model_providers.github-copilot-direct.auth]
command = "gh"
args = ["auth", "token", "--hostname", "github.com", "--user", "YOUR_COPILOT_ACCOUNT"]Then start a fresh Codex session (don't resume the broken one) to drop the stale
previous_response_id. List your accounts with gh auth status.
Codex's web_search is a hosted tool: the model asks Copilot's backend to run the
search server-side — no MCP server and no separate search API key. Enable it with the
top-level setting:
web_search = "live"GPT-5.6 Sol ships as use_responses_lite = true in Codex's bundled catalog, and Responses
Lite omits hosted tools — so Sol needs a catalog override that switches it to full
Responses. Point model_catalog_json at a copy of Codex's catalog with
gpt-5.6-sol -> use_responses_lite = false, and regenerate it after upgrading Codex.
codex # default model
codex -m gpt-5.5 "…" # any responses model, ad-hoc
codex --search "…" # ad-hoc live web search- 401 "input item does not belong to this connection" — multi-account token flip; pin
--user(see above) and start a fresh session. - 401/403 on every request —
ghisn't logged into a Copilot account, or the pinned--useris wrong. Checkgh auth status; confirm withcurl -s -o /dev/null -w '%{http_code}' -H "Authorization: Bearer $(gh auth token --user <acct>)" https://api.githubcopilot.com/models(want200). wire_api = "chat" is no longer supported— remove it; the direct provider needs nowire_api(Codex defaults to responses). Only responses-capable models work.- codex can't find
gh— setcommandto the absolute path (which gh, e.g./opt/homebrew/bin/gh); the auth command may run with a minimal PATH. - GPT-5.6 has no
web_searchtool — regenerate the catalog with Sol on full Responses and confirmweb_search = "live", then start a new Codex process.
Using your Copilot token from a non-editor client may be against your Copilot plan's terms, and heavy automated use can trip Copilot abuse-detection. Use at your own risk.
Remove the [model_providers.github-copilot-direct] block plus the model* / web_search
keys from ~/.codex/config.toml.