Skip to content

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

Closed

Description

@moinulmoin

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

Activity

  1. github-actions commented on Oct 3, 2025

    @github-actions
    Contributor

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

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

  2. wKich commented on Oct 3, 2025

    @wKich

    I've described the same issue here #2941 (comment)

  3. rekram1-node commented on Oct 3, 2025

    @rekram1-node
    Contributor

    does this specifically happen with attachments that are images?

  4. moinulmoin commented on Oct 3, 2025

    @moinulmoin
    Author

    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

  5. rekram1-node commented on Oct 3, 2025

    @rekram1-node
    Contributor

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

  6. naltun commented on Oct 14, 2025

    @naltun

    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.

  7. rekram1-node commented on Oct 14, 2025

    @rekram1-node
    Contributor

    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

  8. xshapira commented on Oct 15, 2025

    @xshapira

    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.

  9. rekram1-node commented on Oct 15, 2025

    @rekram1-node
    Contributor

    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

  10. kaanmertkoc commented on Nov 4, 2025

    @kaanmertkoc
    Contributor

    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.

  11. WilfredLemus commented on Feb 23, 2026

    @WilfredLemus

    Hi! Quick update from my side: I built and published a plugin that works around the GLM clipboard image issue in OpenCode.

    It keeps the same paste UX (Cmd+V / clipboard image) for GLM models by:

    • detecting pasted data:image/... parts,
    • writing the image to a temp local file,
    • replacing the image part with a text instruction that includes the local file path so image MCP tools can process it.
    • It also includes automatic temp cleanup.

    Plugin:

    Install:
    npx -y opencode-glm-clipboard@latest

    This is a temporary workaround while we wait for a native fix in OpenCode.

  12. github-actions commented on Apr 24, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  13. skywalker-35 commented on May 12, 2026

    @skywalker-35

    I'm encountering the exact same error with GLM-5 Turbo in OpenCode TUI (v1.2.x on Windows). Steps to reproduce:

    1. Select glm-5-turbo as the model in OpenCode TUI
    2. Paste an image path (e.g., C:\path\to\screenshot.png)
    3. Send the message
    4. Error: AI_APICallError: API 调用参数有误,请检查文档。 (Invalid API parameter, please check documentation.)

    After investigating, the root cause appears straightforward:

    GLM-5 Turbo is a text-only model — it does NOT support native vision/image input. This is confirmed by:

    • Z.AI official docs: GLM-5-Turbo — no mention of image input support
    • Z.AI official docs: GLM-5V-Turbo — the vision variant with CogViT encoder, released 2026-04-01
    • Zed IDE promote dev -> prod #51892 — same exact error, closed as "GLM-5 was never equipped with visual capabilities"

    When an image is pasted in TUI, OpenCode encodes it as base64 data:image/... and includes it in the API request. GLM-5's API rejects this because it doesn't understand image content blocks in messages. This is consistent with Issue #14673 (data: URL vs file path for MCP) and #5101 (switching from vision to non-vision model breaks thread).

    Workarounds that work today:

    1. Switch to GLM-5V-Turbo — the vision-capable variant of GLM-5, supports image + text input natively
    2. Use @filepath syntax to reference images so MCP tools (look_at, understand_image) can handle them instead of sending images directly to the model
    3. Community plugin: npx -y opencode-glm-clipboard@latest — detects pasted images, saves to temp file, replaces with file path for MCP tools
    4. /compact before switching from a vision model to GLM-5 to clear image history from context

    Suggestion for OpenCode: it would be great if the TUI could detect when the current model doesn't support image input and either:

    • Warn the user before sending
    • Auto-route images through MCP tools transparently
    • Strip image content blocks and warn instead of failing with an API error

    This is essentially the same class of problem as #5101 (which was closed as fixed) — models without vision capability should not have image content sent to them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions