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

Open
opened 2026-02-16 17:33:19 -05:00 by yindo · 10 comments
Owner

Originally created by @moinulmoin on GitHub (Oct 3, 2025).

Originally assigned to: @thdxr on GitHub.

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

Originally created by @moinulmoin on GitHub (Oct 3, 2025). Originally assigned to: @thdxr on GitHub. 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. <img width="2190" height="1098" alt="Image" src="https://github.com/user-attachments/assets/8e876209-06f0-4182-ad7a-8a3fd933d2b3" /> ref: https://docs.z.ai/devpack/mcp/vision-mcp-server
Author
Owner

@github-actions[bot] commented on GitHub (Oct 3, 2025):

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] commented on GitHub (Oct 3, 2025): 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.
Author
Owner

@wKich commented on GitHub (Oct 3, 2025):

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

@wKich commented on GitHub (Oct 3, 2025): I've described the same issue here https://github.com/sst/opencode/issues/2941#issuecomment-3364313110
Author
Owner

@rekram1-node commented on GitHub (Oct 3, 2025):

does this specifically happen with attachments that are images?

@rekram1-node commented on GitHub (Oct 3, 2025): does this specifically happen with attachments that are images?
Author
Owner

@moinulmoin commented on GitHub (Oct 3, 2025):

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 commented on GitHub (Oct 3, 2025): > 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
Author
Owner

@rekram1-node commented on GitHub (Oct 3, 2025):

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

@rekram1-node commented on GitHub (Oct 3, 2025): hm we will need to update models.dev for that then
Author
Owner

@naltun commented on GitHub (Oct 14, 2025):

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 commented on GitHub (Oct 14, 2025): Also hit this error with GLM 4.6 when attaching images: <img width="188" height="37" alt="Image" src="https://github.com/user-attachments/assets/7405ba74-00d1-4dcf-8917-edaaa07ce547" /> <img width="608" height="77" alt="Image" src="https://github.com/user-attachments/assets/36997e29-b00d-4ff3-80d4-e0d0f1428ada" /> 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.
Author
Owner

@rekram1-node commented on GitHub (Oct 14, 2025):

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 commented on GitHub (Oct 14, 2025): 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
Author
Owner

@xshapira commented on GitHub (Oct 15, 2025):

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 commented on GitHub (Oct 15, 2025): > Also hit this error with GLM 4.6 when attaching images: <img alt="Image" width="188" height="37" src="https://private-user-images.githubusercontent.com/7507990/501069174-7405ba74-00d1-4dcf-8917-edaaa07ce547.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjA1MDkyMzksIm5iZiI6MTc2MDUwODkzOSwicGF0aCI6Ii83NTA3OTkwLzUwMTA2OTE3NC03NDA1YmE3NC0wMGQxLTRkY2YtODkxNy1lZGFhYTA3Y2U1NDcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MTAxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTEwMTVUMDYxNTM5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTU0N2IyYzI0MmE2ZDNkNGM0OWRjMTYxNTRhM2FkMmE2OWE1MGI3ZTgxN2I0NTU1OTVjMTAwMjVhZGU1OGY2MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.JK7TyPoT1TvxYrAvV4_tvs1AazzR4645IJOWrBPVuTw"> <img alt="Image" width="608" height="77" src="https://private-user-images.githubusercontent.com/7507990/501069067-36997e29-b00d-4ff3-80d4-e0d0f1428ada.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjA1MDkyMzksIm5iZiI6MTc2MDUwODkzOSwicGF0aCI6Ii83NTA3OTkwLzUwMTA2OTA2Ny0zNjk5N2UyOS1iMDBkLTRmZjMtODBkNC1lMGQwZjE0MjhhZGEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MTAxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTEwMTVUMDYxNTM5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Mzg5ZTNkZTExODA5NWRjNjI0MGIzNGViMzM5OTY4NGUyZDBlNThjMzcwM2Y3YmE4MzQ2ZWU1ZWVjY2Q3M2ZkOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Iha66iizF5wPetNSBABdy8tKZFCJyjqWWg3QoWHRezM"> > > e: it's related to this: [docs.z.ai/devpack/mcp/vision-mcp-server](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. I'm using GLM Coding Max and still having the same issue.
Author
Owner

@rekram1-node commented on GitHub (Oct 15, 2025):

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 commented on GitHub (Oct 15, 2025): 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
Author
Owner

@kaanmertkoc commented on GitHub (Nov 4, 2025):

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 commented on GitHub (Nov 4, 2025): 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1935