Skip to content

System message must be at the beginning - Claude Code

Quick fix

Change the API format for NVIDIA Qwen, or upgrade cc-switch to v3.13.0+ to fix the 400 from providers such as Copilot.

Error output
API Error 400 - System message must be at the beginning.

This cluster mixes several variants producing HTTP 400 (Bad Request). The core mechanism is the request body or auth headers the cc-switch proxy layer builds failing an upstream provider's strict validation. NVIDIA Qwen models on the openai_chat format require the system role message to be first in the messages array; older GitHub Copilot had an incompatibility between the auth header and API path detection; and when the input context exceeds the model window, the adaptation layer calculates a negative max_tokens, which also triggers an upstream 400.

  1. On NVIDIA Qwen models, adjust the API format setting to avoid openai_chat, or make sure the system prompt is merged correctly.

  2. On the GitHub Copilot provider, upgrade cc-switch to v3.13.0 or newer for the authentication and 400 fix.

  3. If the error mentions a negative max_token, reduce the input context in the current session so it stays within the model context window.

ToolClaude Code
Version3.12.3 - 3.16.3
PlatformsWindows
Why does picking API_KEY authentication for GitHub Copilot produce a 400?
A known defect before v3.13.0: choosing API_KEY as the auth field produces incompatible request headers. Upgrading to v3.13.0 resolves it.
What causes a negative max_token (-46551, for example)?
Your input (history plus code) exceeds the model context window (128k, say), so the adaptation layer calculates a negative max_tokens. Clear some context.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.