Format conversion error: Failed to parse upstream response - Claude Code
Quick fix
Upgrade cc-switch for the streaming response parse fix, or enable full request path and complete the URL for non-standard APIs such as iFlytek.
Symptom
Section titled “Symptom”API Error: 422 {"error":{"message":"格式转换错误: Failed to parse upstream response: expected value at line 1 column 1","type":"proxy_error"}}API Error: 422 {"error":{"message":"format conversion error: Failed to parse upstream response: expected value at line 1 column 1","type":"proxy_error"}}
Several different causes share this 422 format conversion error envelope. The most common: some relay or MaaS gateways still return an SSE streaming response to a request with stream:false while labelling the Content-Type application/json, so cc-switch fails parsing it as JSON. Separately, for APIs using a non-standard path such as iFlytek (/v2 rather than /v1), a wrongly assembled path also returns an unexpected format and triggers the same parse error.
Upgrade cc-switch to the latest version. This was fixed structurally on main: on a parse failure the proxy sniffs the response body and, on finding SSE, aggregates it into a normal non-streaming response.
For a non-standard API such as iFlytek MaaS, enable 填充完整请求路径 (fill in the full request path) in cc-switch settings.
Complete the full path in the API address config by hand — append /chat/completions to the URL, for example — or switch to an officially supported Anthropic protocol endpoint such as https://maas-coding-api.cn-huabei-1.xf-yun.com/anthropic.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 3 real issues
- Why does the first request work while later ones 422 frequently?
- A defect in how the streaming request is judged: the proxy only read the stream value from the first request, so later requests could fail conversion. Upgrade to the latest version for the fix.
- Is "Your input exceeds the context window of this model" also a format conversion error?
- No — that means your input exceeded the model context window. Compact your input and try again.
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.