Skip to content

API Error: 422 format conversion error: Empty choices array Claude Code

Quick fix

The upstream NVIDIA NIM GLM-5.2 model intermittently returns an empty choices array. Turn on failover in cc-switch or retry the request.

Error output
API Error: 422 格式转换错误: Empty choices array
English translation

API Error: 422 format conversion error: Empty choices array

Calling the z-ai/glm-5.2 model through an upstream API such as NVIDIA NIM, the API occasionally returns a response carrying only usage statistics with choices as an empty array (particularly on large requests of 100-500KB, at roughly a 10-20% failure rate).

The cc-switch desktop build fixed this for the streaming case in v3.16.3, but the CLI build that Claude Code uses has not fully fixed that OpenAI format conversion logic, so parsing the empty array throws a 422 or a 502.

  1. Configure failover for the current model in cc-switch so an empty choices error falls back to another API interface automatically.

  2. Retry the request. The error is an intermittent upstream API problem, and resending usually succeeds.

ToolClaude Code
Version3.16.5 - 3.19.1 (affected range)
PlatformsmacOSWindows
Why does the desktop build not error while only Claude Code does?
The desktop build fixed the usage-only trailing packet with choices:[] in a streaming response in v3.16.3, but the CLI build Claude Code depends on has not picked up that conversion fix yet.
Is this error a cc-switch problem or an upstream API problem?
The root cause is the upstream API (NVIDIA NIM) returning an empty choices array that does not conform to the standard OpenAI format, but the cc-switch CLI build lacks tolerance for that malformed response.

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.