You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AI_APICallError: The messages parameter is illegal. Please check the documentation. - Zhipu AI GLM-4.5 #2557
Zhipu AI GLM-4.5 regularly hangs mid edit and waits for a response after the message "AI_APICallError: The messages parameter is illegal. Please check the documentation."
Edit: I don't think it is mid-edit. It seems to happen after session compaction. And it seems to then start its memory again from the last session.
Only settings that are none default are z.ai's recommended setup for 'Coding Plan' on opencode. In ~/.config/opencode/opencode.json I have:
I'm still getting the message in the latest version. It's a shame, because apart from that, glm-4.5 runs very fast and intelligently in opencode compared to other cli tools I'm testing. Sadly, this error makes it pretty unusable, as I can't leave it unattended, and need to re-prompt the AI constantly to get it to continue after this error. My workflow is to set all permissions to allow and run it sandboxed in a VM, then connect through a mosh session on my phone. I'm not the only person that uses this type of workflow.
Yea, I just saw that and tested it. It solves the issue. Thanks! I won't close for now in case anyone has any tweaks or recommendations to offer. Otherwise, feel free to close.
Yeah I meant like where does the provider say this
Nowhere in the docs, but looks like the OpenAI format shows the CoT/Thinking but using the Anthropic compatible API DOES NOT show it, or maybe it is missing it altogether.
would love to see this fixed as well, I am using GLM-4.5 heavily as well, with subscription. I didn't switch to anthropic, this model is better with reasoning.
My best guess from diagnosing the problem is that it's an upstream issue with the inference software. The tool call template might not be able to handle hallucinated output from the model gracefully (i.e. when it makes up a tool name that wasn't provided in the request).
That guess is based on the fact that this occurs far more often when tools are restricted, or nearly guaranteed if I ask it to use a nonexistent tool.
Now try calling a made up tool: `foogah`.
User (03:35 PM)
The tool foogah doesn't exist. Available tools are: bash, edit, webfetch, glob, grep, list, read, write, todowrite, toread, task.
Build glm-4.5 (03:35 PM)
Try anyway. It should cause an error.
User (03:36 PM)
AI_InvalidResponseDataError: Expected 'id' to be a string.
oh shoot, you're right. I did reproduce it too. can we silently ignore this error or maybe report it to llm?
That depends on if there's something to salvage, but I think in this situation you see no streaming response at all.
Technically z.ai and other inference providers need to patch the bug and have the API behave more like OpenAI: GPT will happily return a hallucinated tool name in the response, leaving it up to the client (OpenCode) to deal with. Not sure what a good workaround here would be.
Just want to say thankyou for this fix. glm-4.5 coder plan with opencode and openai endpoint is now ridiculously powerful -- almost too good to be true. I'll enjoy it while it lasts and z.ai sustain these prices. opencode has the best cli implementation I've tested.
Though unfortunately "AI_InvalidResponseDataError: Expected 'id' to be a string." is still bringing it to a halt at times, but it's still an improvement.
@rekram1-node sure, but there´s nothing special in there, i only removed the mcps and one custom provider that is NOT used here....
here´s what's left:
@rekram1-node nope, just using an api key that is connected to a pre-pay account with some $ in it.
in hope i am not mixing things up, i am talking about using a key from: https://z.ai/manage-apikey/apikey-list
Z.AI and Zhipu AI are marketed as two separate providers from the company Zhipu. Former facing international users, and the latter facing Chinese users. If you obtained the API key from https://z.ai, use the Z.AI provider.
Activity
github-actions commentedon Sep 12, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
rekram1-node commentedon Sep 13, 2025
if this was happening at random intervals (like after compacts) can you try latest? There were some fixes shipped today
jgwhite0111 commentedon Sep 14, 2025
I'm still getting the message in the latest version. It's a shame, because apart from that, glm-4.5 runs very fast and intelligently in opencode compared to other cli tools I'm testing. Sadly, this error makes it pretty unusable, as I can't leave it unattended, and need to re-prompt the AI constantly to get it to continue after this error. My workflow is to set all permissions to allow and run it sandboxed in a VM, then connect through a mosh session on my phone. I'm not the only person that uses this type of workflow.
rekram1-node commentedon Sep 14, 2025
I haven't tested but someone in the discord said:
ex:
jgwhite0111 commentedon Sep 14, 2025
Yea, I just saw that and tested it. It solves the issue. Thanks! I won't close for now in case anyone has any tweaks or recommendations to offer. Otherwise, feel free to close.
shekohex commentedon Sep 14, 2025
But you now would lose the CoT and reasoning from the model.
jgwhite0111 commentedon Sep 15, 2025
OK so the Anthropic API doesn't suport reasoning? I think I'd rather put up with re-prompting it than lose reasoning for now.
vinaychilukuri commentedon Sep 15, 2025
Have been facing the same issue! And, I also don't want to lose reasoning at this point.
0serna commentedon Sep 16, 2025
Same problem here, today I've been getting this error repeatedly in opencode v0.9.5
rekram1-node commentedon Sep 16, 2025
Where does it say you lose CoT reasoning? just curious maybe I missed it
jgwhite0111 commentedon Sep 16, 2025
In the replies above from shekohex:
rekram1-node commentedon Sep 16, 2025
Yeah I meant like where does the provider say this
shekohex commentedon Sep 16, 2025
Nowhere in the docs, but looks like the OpenAI format shows the CoT/Thinking but using the Anthropic compatible API DOES NOT show it, or maybe it is missing it altogether.
aemr3 commentedon Sep 16, 2025
would love to see this fixed as well, I am using GLM-4.5 heavily as well, with subscription. I didn't switch to anthropic, this model is better with reasoning.
18 remaining items
aemr3 commentedon Sep 17, 2025
oh shoot, you're right. I did reproduce it too. can we silently ignore this error or maybe report it to llm?
jdiaz5513 commentedon Sep 17, 2025
That depends on if there's something to salvage, but I think in this situation you see no streaming response at all.
Technically z.ai and other inference providers need to patch the bug and have the API behave more like OpenAI: GPT will happily return a hallucinated tool name in the response, leaving it up to the client (OpenCode) to deal with. Not sure what a good workaround here would be.
The chat template for GLM 4.5 is tricky, so I have some sympathy.
jgwhite0111 commentedon Sep 18, 2025
Just want to say thankyou for this fix. glm-4.5 coder plan with opencode and openai endpoint is now ridiculously powerful -- almost too good to be true. I'll enjoy it while it lasts and z.ai sustain these prices. opencode has the best cli implementation I've tested.
jgwhite0111 commentedon Sep 18, 2025
Though unfortunately "AI_InvalidResponseDataError: Expected 'id' to be a string." is still bringing it to a halt at times, but it's still an improvement.
brokechubb commentedon Sep 20, 2025
It is worse than ever using 0.10.3
michabbb commentedon Sep 28, 2025
opencode v0.12.1
Zhipu AI GLM-4.5
Whatever I send (for example, a simple "hi") shows the error: AI_APICallError: API 调用参数有误,请检查文档。
rekram1-node commentedon Sep 28, 2025
@michabbb can u share your opencode.json?
michabbb commentedon Sep 28, 2025
@rekram1-node sure, but there´s nothing special in there, i only removed the mcps and one custom provider that is NOT used here....
here´s what's left:
{ "$schema": "https://opencode.ai/config.json", "theme": "github", "model": "groq/moonshotai/kimi-k2-instruct-0905", "autoupdate": true, "permission": { "bash": { "rm": "ask" } }, "agent": { "ask": { "mode": "primary", "tools": { "*": false }, "prompt": " " } }, }rekram1-node commentedon Sep 28, 2025
@michabbb are you on their coding plan subscription?
michabbb commentedon Sep 28, 2025
@rekram1-node nope, just using an api key that is connected to a pre-pay account with some $ in it.
in hope i am not mixing things up, i am talking about using a key from: https://z.ai/manage-apikey/apikey-list
i am confused, because: https://models.dev/?sort=output-costper&order=asc&search=GLM-4.5
shows "z.ai" and "Zhipu AI" as two different providers but in opencode i can only choose "Zhipu AI" - but whats the difference here ? 🙈
fwang commentedon Sep 28, 2025
Z.AI and Zhipu AI are marketed as two separate providers from the company Zhipu. Former facing international users, and the latter facing Chinese users. If you obtained the API key from
https://z.ai, use the Z.AI provider.michabbb commentedon Sep 28, 2025
@fwang thanks a lot for clarification, i was wondering why i do see "Zhipu Ai" but not "Z.Ai", now i know. because i used the wrong one 🙈
@rekram1-node sorry for the noise! 😞
rekram1-node commentedon Sep 28, 2025
hey no problem
ShamanicArts commentedon Oct 2, 2025
I am also seeing a lot of
AI_APICallError: Invalid API parameter, please check the documentation.errors suddenly. not sure the cause