When to use this
Use this guide if you want:
- Claude Code to use Copilot-provided Claude models without a separate Anthropic API key.
- MuxLayer to exchange a GitHub OAuth token for a Copilot API credential automatically.
- Tool continuations and history compaction requests tagged as agent traffic so they do not consume premium user requests.
- Logs that show the
x-initiatorclassification per request.
Risk disclosure
This feature is optional. If you do not add a copilot provider, MuxLayer never uses this path.
Using a Copilot subscription outside official clients is a terms-of-service gray area. Community tools with similar behavior have existed for a long time, but account risk cannot be ruled out. Avoid using important corporate accounts for experiments.
Quick Setup
- Make sure you have an active GitHub Copilot subscription.
- Get a GitHub OAuth token. If you are signed into VS Code Copilot, check
~/.config/github-copilot/apps.jsonforoauth_token. - Open MuxLayer, go to Providers, and add a provider with type GitHub Copilot.
- Paste the
gho_orghu_token as the API key. MuxLayer fills the base URL and model list. - Start the gateway from Overview or Gateway.
- Open Clients and apply the Claude Code config.
- Send a test message and check Logs for provider
GitHub Copilotandx-initiatorclassification.
What MuxLayer handles
| Area | Behavior |
|---|---|
| Credential exchange | GitHub OAuth token is exchanged for a Copilot bearer credential and renewed automatically. |
| Storage | Copilot credentials are cached by hash and are not stored as plaintext tokens. |
| Premium request classification | User messages are tagged as user traffic; tool continuations and compaction are tagged as agent traffic. |
| Model names | Claude Code model names such as claude-sonnet-4-6 are normalized to Copilot's expected form. |
Troubleshooting
| Symptom | Check |
|---|---|
| Token exchange fails | Confirm the token starts with gho_ or ghu_ and belongs to an account with Copilot access. |
| Model is rejected | Check the Copilot provider's model list after saving the provider. |
| Premium requests look higher than expected | Open request logs and compare x-initiator: user vs x-initiator: agent. |
| You want to avoid this path | Remove or disable the Copilot provider and use DeepSeek, MiMo, Anthropic, or another provider. |