Skip to content

System message must be at the beginning.: Claude Code

Quick fix

Change Claude Code's "model" from "opus" to "haiku" or another model family to avoid an OpenAI-compatible API 400 response.

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

When cc-switch proxies an OpenAI-compatible chat API, requests from Claude Code using the "opus" model family retain a system message that is not first. The backend requires role: system to be the first item in the messages array, so it rejects the request with 400.

In this issue, the "haiku" model family uses a different message-building path, where the system message happens to be first, so the session works normally. The issue suggests cc-switch should normalize system-message order when converting Anthropic requests to OpenAI Chat Completions, but the issue remains open.

  1. In Claude Code's cc-switch configuration, change "model" from "opus" to "haiku", or use another model family.

  2. Restart the Claude Code session and confirm that this 400 error no longer appears.

ToolClaude Code
Version3.20.4(受影响版本)
PlatformsmacOS

(No FAQ yet)

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.