Invalid type for 'messages': expected an array - Codex
Quick fix
Upgrade cc-switch to the latest version for the conversion fix, or downgrade the Codex CLI to 0.80.0 and use wire_api="chat" to work around it.
Symptom
Section titled “Symptom”Invalid type for 'messages': expected an array of objects, but got null instead.From Codex CLI 0.99 on, the wire_api = "chat" option was removed officially, forcing the Responses API. When cc-switch tries to forward a Codex Responses API request (carrying an input field) to an upstream that only supports Chat Completions — MiniMax or JD Cloud, for example — a defect in the conversion logic fails to map input into a messages array, leaving messages null. The upstream API validation fails and returns HTTP 400.
Upgrade cc-switch to the latest version, where the Responses API to Chat Completions conversion logic is fixed.
If you cannot upgrade cc-switch yet, downgrade the Codex CLI to 0.80.0 (the last version supporting chat mode) and edit the Codex config file:
~/.codex/config.toml wire_api = "chat"
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 4 real issues
- #2806Codex responses → chat translator forwards `messages: null` to upstream (0.99+ wire_api=responses required)
- #2832[Bug] MiniMax provider: Responses → Chat Completions 转换后 messages 字段为 null
- #2833[Bug] MiniMax provider: Responses → Chat Completions 转换后 messages 字段为 null
- #2834[Bug] MiniMax provider: Responses → Chat Completions 转换后 messages 字段为 null
- Why does requesting the upstream API directly with curl not error?
- The upstream API itself is healthy. The error happens because cc-switch, as the middleware, fails to build the messages array during protocol conversion, so what upstream actually receives is null.
Related problems
Section titled “Related problems”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.