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.
Symptom
Section titled “Symptom”API Error: 422 格式转换错误: Empty choices arrayAPI 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.
Configure failover for the current model in cc-switch so an empty choices error falls back to another API interface automatically.
Retry the request. The error is an intermittent upstream API problem, and resending usually succeeds.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 2 real issues
- 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.
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.