Skip to content

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.

Error output
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.

  1. Upgrade cc-switch to the latest version, where the Responses API to Chat Completions conversion logic is fixed.

  2. 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"
ToolCodex
Version>= 0.99.0
PlatformsWindowsmacOS
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.

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.