Skip to content

feat(ai): add Z.ai image generation#37780

Open
opencode-agent[bot] wants to merge 2 commits into
v2from
zai-images
Open

feat(ai): add Z.ai image generation#37780
opencode-agent[bot] wants to merge 2 commits into
v2from
zai-images

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a first-class ZAI.configure(...).image(modelID) facade with ZAI_API_KEY bearer fallback and provider export
  • reuse the image HTTP transport/parser while keeping OpenAI and Z.ai request schemas, response schemas, and protocol-owned overlay fields isolated
  • validate Z.ai userID length and content-filter roles/levels from the official contract without restricting model IDs or image sizes to a catalog
  • document Z.ai image configuration and the 30-day temporary output URL lifetime
  • add deterministic protocol coverage and a redacted live cassette

Live evidence

  • recorded the international https://api.z.ai/api/paas/v4/images/generations route
  • downloaded and decoded the returned image: valid 1024x1024, 8-bit sRGB JPEG
  • visually inspected the result and confirmed the requested centered red circle on a white background
  • scanned the cassette for API key and authorization material, then replayed it successfully

Tests

  • bun x prettier --check ...
  • bun typecheck
  • bun run build
  • bun test --timeout 30000 --only-failures (356 passed, 29 skipped)
  • RECORDED_PROVIDER=zai bun test test/provider/zai-images.recorded.test.ts --timeout 30000
  • git diff --check
  • bounded secret scan of changed files and the Z.ai cassette

CI attribution

  • the prior Linux e2e failure was unrelated: packages/app/e2e/regression/review-line-comment.spec.ts could not obtain line-number DOM bounds after retries
  • this PR changes only packages/ai; the prior Linux AI unit job passed

Limitations

  • international Z.ai endpoint and credentials only
  • direct hosted text-to-image generation only; no hosted editing or conversational tools
  • model selectors and image sizes remain structurally validated rather than catalog-restricted
  • Z.ai output URLs are temporary and expire after 30 days; callers must persist images they need to retain

Requested by: @rekram1-node (Aiden Cline via Slack)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant