openclaw - ✅(Solved) Fix Image tool returns 404 for ZAI vision models (zai/glm-4.6v) [2 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#70886Fetched 2026-04-24 10:38:17
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
cross-referenced ×2commented ×1

Fix Action

Fixed

PR fix notes

PR #70908: Route Z.AI vision models to non-coding host on Coding Plan endpoints

Description (problem / solution / changelog)

Summary

Fixes #70886. The built-in image tool returned a 404 whenever agents.defaults.imageModel pointed at a Z.AI vision model (for example zai/glm-4.6v) and the Z.AI provider had been onboarded with a Coding Plan key. Z.AI's Coding Plan endpoints do not expose vision models, so the shared provider baseUrl must not be used for them.

Root cause

extensions/zai/onboard.ts previously applied a single provider-level baseUrl to every entry in the Z.AI catalog. When a user onboarded with --auth-choice zai-coding-global or --auth-choice zai-coding-cn, https://api.z.ai/api/coding/paas/v4 (or the CN equivalent) became the only route for every model, including glm-4.6v, glm-4.5v, and glm-5v-turbo. Those vision models are only served from the non-coding paths (…/paas/v4), so the image tool's chat/completions request resolved to a path that does not exist, returning 404.

Fix

  • Add isZaiCodingBaseUrl and resolveZaiNonCodingBaseUrl helpers in extensions/zai/model-definitions.ts that map a coding base URL back to the matching non-coding host on the same origin (api.z.ai or open.bigmodel.cn).
  • While building the Z.AI catalog during onboarding, attach a per-model baseUrl to the vision entries (glm-4.6v, glm-4.5v, glm-5v-turbo) when the resolved provider baseUrl is a coding endpoint. pi-coding-agent's model registry already prefers per-model baseUrl over the provider-level URL, so vision requests go to …/paas/v4 while text/coding models continue to use the configured coding path.

Why the fix is safe

  • Text and coding models keep the configured provider baseUrl; only vision entries gain a per-model override, and only when the provider is already pointed at a Coding Plan endpoint.
  • The override maps each coding URL back to the non-coding path on the same originapi.z.aiapi.z.ai and open.bigmodel.cnopen.bigmodel.cn. No new hosts, CORS surfaces, or trust boundaries are introduced; all four URLs were already defined and tested in this module.
  • Authentication is unchanged: Z.AI uses the same Bearer API key for coding and non-coding paths, and auth choices, env var names, and provider metadata are untouched.

Security / runtime controls unchanged

  • No changes to prompt text, tool catalog, or any policy decision. Routing is enforced at the runtime transport layer via the already-validated ModelDefinitionConfig.baseUrl field honored by @mariozechner/pi-coding-agent's ModelRegistry.parseModels.
  • No changes to ZAI_API_KEY / Z_AI_API_KEY resolution, auth storage, headers, SSRF posture, or host env allow/deny lists.
  • No changes to default onboarding: openclaw onboard without an explicit coding choice still lands on ZAI_GLOBAL_BASE_URL, so vision entries carry no baseUrl override in that path.

Tests run

  • pnpm vitest run extensions/zai/onboard.test.ts extensions/zai/model-definitions.test.ts — 10 tests pass, including two new regressions asserting that coding-global/coding-cn onboard produces vision baseUrl overrides to ZAI_GLOBAL_BASE_URL/ZAI_CN_BASE_URL and that non-coding onboard paths do not add overrides.
  • pnpm test:extension zai — 4 files / 20 tests pass.
  • pnpm vitest run src/agents/tools/image-tool.test.ts — 46 tests pass.
  • pnpm test:contracts:plugins — 51 files / 637 tests pass.
  • pnpm check — typecheck, lint, and policy guards pass.

Made with Cursor

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/zai/model-definitions.ts (modified, +16/-0)
  • extensions/zai/onboard.test.ts (modified, +108/-1)
  • extensions/zai/onboard.ts (modified, +85/-18)

PR #70915: fix(zai): route vision models to standard endpoint instead of coding endpoint (#70886)

Description (problem / solution / changelog)

Summary

Fixes #70886

Issue

Image tool returns 404 for ZAI vision models (zai/glm-4.6v)

Root Cause

When the ZAI provider is configured with a coding endpoint (e.g. api.z.ai/api/coding/paas/v4), vision models like glm-4.6v return 404 because the coding endpoint does not support image understanding requests.

Direct API calls to the standard endpoint (api.z.ai/api/paas/v4/chat/completions) work correctly, confirming the coding endpoint does not serve vision models.

Solution

Override the baseUrl for ZAI vision models (glm-4.6v, glm-4.5v, glm-5v-turbo) in the media understanding provider. When a coding endpoint is detected, strip the /coding path segment to route vision model requests to the standard endpoint that supports multimodal requests.

Changes

  • extensions/zai/media-understanding-provider.ts: Added patchCfgForVisionModel() that detects coding endpoints for vision models and overrides to standard endpoint. Custom describeImage/describeImages wrappers apply this patch before calling the generic functions.
  • extensions/zai/media-understanding-provider.test.ts: Unit tests for vision model detection, coding endpoint detection, URL transformation, and config patching logic.

Testing

  • TypeScript compilation passes (tsc --noEmit)
  • All 10 unit tests pass

This PR was automatically generated by a daily automation task. 🤖 Generated with Claude Code

Changed files

  • extensions/zai/media-understanding-provider.test.ts (added, +95/-0)
  • extensions/zai/media-understanding-provider.ts (modified, +70/-3)

Code Example

Image model failed (zai/glm-4.6v): 404 "Not Found"

---

[tools] image failed: Image model failed (zai/glm-4.6v): 404 "Not Found" raw_params={"image":"https://picsum.photos/seed/test42/600/400","prompt":"Describe this image briefly."}
RAW_BUFFERClick to expand / collapse

Bug

The built-in image tool returns 404 "Not Found" when agents.defaults.imageModel is set to a ZAI vision model (e.g. zai/glm-4.6v).

The model works correctly via direct API calls (curl/SDK), so this is an internal routing issue within OpenClaw's image tool pipeline.

Reproduction

  1. Set agents.defaults.imageModel to zai/glm-4.6v in openclaw.json
  2. Ensure ZAI auth is configured and working (other ZAI tools like MCP web search work fine)
  3. Restart gateway, start new session
  4. Call the image tool with any valid image URL

Expected

Image analysis response from GLM-4.6V.

Actual

Image model failed (zai/glm-4.6v): 404 "Not Found"

Environment

  • OpenClaw gateway: v2026.4.22 (systemd reports 2026.4.12 — stale binary label)
  • Node: v25.9.0
  • OS: Arch Linux 6.19.11-arch1-1 (x64)
  • Model: zai/glm-4.6v

Notes

  • ZAI auth is confirmed working — web_fetch, MCP web search, MCP web reader, and MCP zread all function correctly with the same auth profile
  • Direct API call to https://open.bigmodel.cn/api/paas/v4/chat/completions with the same model and API key succeeds for both text and image inputs
  • The 404 appears to come from within OpenClaw's complete() call — possibly hitting the wrong endpoint for ZAI vision models specifically

Log excerpt

[tools] image failed: Image model failed (zai/glm-4.6v): 404 "Not Found" raw_params={"image":"https://picsum.photos/seed/test42/600/400","prompt":"Describe this image briefly."}

extent analysis

TL;DR

The issue can likely be resolved by updating the internal routing within OpenClaw's image tool pipeline to correctly handle ZAI vision models.

Guidance

  • Verify that the complete() call is indeed hitting the wrong endpoint for ZAI vision models by checking the API endpoint used in the complete() call and comparing it to the working direct API call endpoint.
  • Check the OpenClaw documentation to see if there are any specific configuration options or workarounds for using ZAI vision models with the image tool.
  • Test the image tool with a different ZAI vision model to see if the issue is specific to the zai/glm-4.6v model.
  • Review the OpenClaw code to see if there are any hardcoded endpoints or model-specific logic that may be causing the issue.

Example

No code snippet is provided as the issue is related to internal routing and configuration.

Notes

The issue appears to be specific to the OpenClaw image tool and ZAI vision models, and may require updates to the OpenClaw code or configuration to resolve.

Recommendation

Apply workaround: Update the internal routing within OpenClaw's image tool pipeline to correctly handle ZAI vision models, or use a different ZAI vision model that is known to work with the image tool.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Image tool returns 404 for ZAI vision models (zai/glm-4.6v) [2 pull requests, 1 comments, 1 participants]