opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Getting "AI_APICallError: Invalid API parameter, please check the documentation." in opencode with zAI glm 4.6

Open moinulmoin opened this issue 1 month ago • 10 comments
trafficstars

I have ZAI coding plan that I use with opencode . ZAI use vision mcp server for image/image and text input. It works fine in factory cli or claude code. but when I use image/image and text input in opencode and glm 4.6 it throws this error.

Image

ref: https://docs.z.ai/devpack/mcp/vision-mcp-server

moinulmoin avatar Oct 03 '25 07:10 moinulmoin

This issue might be a duplicate of existing issues. Please check:

  • #2898: GLM Coding Plan - Frequent Errors (reports same "Invalid API Parameter. Check the documentation." error with GLM models, especially pronounced in 4.6)
  • #2557: AI_APICallError: The messages parameter is illegal. Please check the documentation. - Zhipu AI GLM-4.5 (similar API parameter error with z.ai GLM configuration)
  • #2903: GLM-4.6 model fails to use web search tools (GLM-4.6 specific issues with tool usage, though different symptoms)

Feel free to ignore if none of these address your specific case with MCP vision server integration.

github-actions[bot] avatar Oct 03 '25 07:10 github-actions[bot]

I've described the same issue here https://github.com/sst/opencode/issues/2941#issuecomment-3364313110

wKich avatar Oct 03 '25 12:10 wKich

does this specifically happen with attachments that are images?

rekram1-node avatar Oct 03 '25 14:10 rekram1-node

does this specifically happen with attachments that are images?

yes yes specifically happen with attachments that are images, because glm 4.6 doesnt support image input and need to use vision mcp server, which works well with droid cli and claude code cli

moinulmoin avatar Oct 03 '25 16:10 moinulmoin

hm we will need to update models.dev for that then

rekram1-node avatar Oct 03 '25 17:10 rekram1-node

Also hit this error with GLM 4.6 when attaching images: Image Image

e: it's related to this: https://docs.z.ai/devpack/mcp/vision-mcp-server

tl;dr Image and Video processing is only available with GLM Coding Pro plans and up. I am using GLM Coding Lite and can validate this.

naltun avatar Oct 14 '25 17:10 naltun

Yeah ig they don't support them, we can make the tui guard against this pretty easily tho, to be able to continue your convo I recommend doing a /undo and then deleting the image attachments

rekram1-node avatar Oct 14 '25 17:10 rekram1-node

Also hit this error with GLM 4.6 when attaching images: Image Image

e: it's related to this: docs.z.ai/devpack/mcp/vision-mcp-server

tl;dr Image and Video processing is only available with GLM Coding Pro plans and up. I am using GLM Coding Lite and can validate this.

I'm using GLM Coding Max and still having the same issue.

xshapira avatar Oct 15 '25 06:10 xshapira

Are you sending images?

It looks like there is a special mcp server they want you to be using, if it is an mcp server then @ ing the file won't work correctly, nor will a drag and drop (because they are unrelated to mcp servers).

In this case the llm would have to call the mcp server tool right

rekram1-node avatar Oct 15 '25 06:10 rekram1-node

Hey! Encountered this too. Wondering if it'd make sense to have opencode detect this pattern and smooth it out:

  1. When GLM-4.6 user attaches an image and hits this error
  2. Show a prompt: "GLM-4.6 vision requires the Z.AI Vision MCP Server. Would you like to add it now?"
  3. If yes → auto-run the MCP installation
  4. Resume conversation with image routed to MCP tool

Curious what you think happy to explore implementation if it resonates.

kaanmertkoc avatar Nov 04 '25 23:11 kaanmertkoc