You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BYOK: providers.json is ignored without COPILOT_PROVIDER_BASE_URL — no file-based activation; --model silently substitutes a subscription model #5343
I'm trying to use my own model provider (an OpenAI-compatible endpoint) together with plugins that make their own copilot -p calls from hook processes, and I keep running into what looks like a gap in how BYOK mode gets activated.
copilot help providers says BYOK is activated by the COPILOT_PROVIDER_BASE_URL env var. I was hoping providers.json would work as the file-based equivalent, since it already accepts a static apiKey/bearerToken (what #4936 and #5287 are about). Mine looks like this:
But with that in place and noCOPILOT_PROVIDER_* env vars, this:
copilot -p "Reply with exactly: OK" --model mymodel --output-format json
gives me:
session.info {"infoType": "model_unavailable", "message": "Model \"mymodel\" is no longer available. Using \"claude-sonnet-5.5\" instead."}
model.call_final_result {"model": "claude-sonnet-5.5", "isByok": false, "result": "success"}
So the --model I asked for quietly gets dropped and the request runs on my Copilot subscription instead. If I delete providers.json the same command fails loudly ("Model "mymodel" from --model flag is not available"), so the file is being read and the model is recognized — it's just unusable unless the env var flips BYOK on.
When I do set COPILOT_PROVIDER_BASE_URL (plus COPILOT_PROVIDER_TYPE / _WIRE_API), the request finally goes to my provider ("isByok": true) — but the apiKey sitting in providers.json still isn't used. The request goes out unauthenticated and I get session.error: "Authentication failed with provider at … (HTTP 401)". Only COPILOT_PROVIDER_API_KEY / _BEARER_TOKEN from the environment authenticate.
This matters for me beyond interactive use: plugins that call copilot -p from hook processes (I use microsoft/TokenEconomizer, whose loop guard and fact proposer work exactly this way) can't reach BYOK at all, because hooks don't inherit the session's COPILOT_PROVIDER_*. Before I figured out what was going on I got "not signed in" errors; after "fixing" it with providers.json my calls silently started billing my Copilot subscription instead of my own provider, which honestly feels worse.
What I'd love to see:
providers.json alone activates BYOK (env vars keep working as an override)
Activity