Problem: GitHub Copilot Business and Enterprise accounts get HTTP 421 (Misdirected Request) errors when using OpenClaw. This repository explains the root cause and provides a workaround.
OpenClaw uses the api.individual.githubcopilot.com endpoint by default. However, GitHub Copilot token exchange provides account-tier-specific endpoints via the token's proxy-ep field:
| Account Type | Token proxy-ep |
Correct Endpoint | Current Behavior |
|---|---|---|---|
| Individual | proxy.individual.githubcopilot.com |
api.individual.githubcopilot.com |
✅ Works |
| Business | proxy.business.githubcopilot.com |
api.business.githubcopilot.com |
❌ 421 error |
| Enterprise | proxy.enterprise.githubcopilot.com |
api.enterprise.githubcopilot.com |
❌ 421 error |
Root Cause: The token-derived baseUrl is never applied at runtime. All requests fall through to the hardcoded api.individual endpoint, which rejects Business/Enterprise tokens with HTTP 421.
Add this to ~/.openclaw/openclaw.json:
{
"models": {
"providers": {
"github-copilot": {
"baseUrl": "https://api.business.githubcopilot.com",
"models": []
}
}
}
}Replace business with enterprise if you have an Enterprise account.
Restart OpenClaw:
openclaw gateway restartThe config workaround survives updates as long as you don't clear the config file. To automate it, use the provided ensure-copilot-baseurl.py script.
# Copy the script
mkdir -p ~/.local/lib
cp ensure-copilot-baseurl.py ~/.local/lib/
# Make it executable
chmod +x ~/.local/lib/ensure-copilot-baseurl.py
# Test it
python3 ~/.local/lib/ensure-copilot-baseurl.pyAdd this to your systemd service file (~/.config/systemd/user/openclaw-gateway.service):
[Service]
ExecStartPre=/usr/bin/python3 /home/YOUR_USERNAME/.local/lib/ensure-copilot-baseurl.py
ExecStart=/path/to/node /path/to/openclaw/dist/index.js gatewayThen reload and restart:
systemctl --user daemon-reload
systemctl --user restart openclaw-gatewayThe script will silently run before every gateway start and ensure the baseUrl is set correctly. Exit code is always 0 — it will never block startup.
A code fix is in progress that automatically applies the token-derived baseUrl at runtime:
- PR #29614: Primary fix in OpenClaw source
- PR #44136: Follow-up addressing reviewer concerns (user-config priority)
Once merged, you won't need the workaround anymore.
Run the provided test-fix.sh script to verify the fix is applied:
bash test-fix.shThis checks:
- ✅
openclaw.jsonexists and is valid JSON - ✅
models.providers.github-copilot.baseUrlis configured - ✅ The baseUrl matches your account tier
- ✅ OpenClaw gateway can start
- Issue #41379: OpenClaw 2026.3.8, Copilot Business → 421
- Issue #8366: OpenClaw gpt-5.2-codex → 421
- Issue #17508: Copilot-proxy usage broken
- PR #29614: Code fix (in review)
- PR #44136: Follow-up with priority logic
- OpenClaw 2026.3.8
- GitHub Copilot Business account
- Ubuntu Linux with systemd user service
- Models: GPT-5.1-Codex, GPT-5.2-Codex, GPT-5.3-Codex, Claude models
- OpenClaw: 2026.3.8+
- Node.js: 18+ (via linuxbrew or system)
- Python: 3.8+
- Git: Any recent version
If you're still seeing 421 errors after applying the workaround:
- Verify
~/.openclaw/openclaw.jsonhas the correctbaseUrl - Restart the gateway:
openclaw gateway restart - Check logs:
journalctl --user -u openclaw-gateway -f - Comment on the related GitHub issues with your OpenClaw version and account tier
This guide and scripts are provided as-is for troubleshooting purposes.