Skip to content

Add native OpenClaw image-generation support via ZenMux Gemini/Vertex route #1

Description

@abnershang

Summary

The official OpenClaw plugin currently registers ZenMux only as an LLM provider. OpenClaw therefore cannot select ZenMux for its native image.generate capability, even though the ZenMux catalog includes image-output models such as google/gemini-3.1-flash-image.

Current behavior

After installing @zenmux/openclaw-plugin@0.1.2 and completing OAuth:

  • zenmux appears in the LLM provider registry.
  • The plugin manifest does not declare contracts.imageGenerationProviders.
  • The plugin does not call api.registerImageGenerationProvider(...).
  • Configuring agents.defaults.imageGenerationModel.primary as zenmux/google/gemini-3.1-flash-image does not work without an additional adapter.

Routing the model through an OpenAI-compatible /images/generations endpoint is also incorrect. The working ZenMux route is the Gemini/Vertex-compatible endpoint:

POST https://zenmux.ai/api/vertex-ai/v1/publishers/google/models/gemini-3.1-flash-image:generateContent

with generationConfig.responseModalities: ["TEXT", "IMAGE"]. Image bytes are returned in candidate content parts as inlineData / inline_data.

Expected behavior

The official plugin should expose ZenMux as an OpenClaw image-generation provider and reuse the existing ZenMux OAuth credential/refresh flow.

Suggested model reference:

zenmux/google/gemini-3.1-flash-image

Suggested implementation

  • Add imageGenerationProviders: ["zenmux"] to the plugin manifest contract.
  • Register an image-generation provider with api.registerImageGenerationProvider.
  • Resolve request-ready credentials through OpenClaw runtime model auth so OAuth refresh remains provider-owned.
  • Map OpenClaw prompt, input images, aspect ratio, resolution, and output format to ZenMux Vertex generateContent.
  • Parse base64 image parts from candidates[].content.parts[].inlineData and inline_data.
  • Keep response-size and timeout limits bounded.
  • Add unit tests for request mapping, OAuth credential resolution, error responses, and image parsing.

Verification performed

A small local companion provider using the route above generated a real 1024×1024 PNG successfully with:

  • provider: zenmux
  • model: google/gemini-3.1-flash-image
  • route: vertex-generateContent

One earlier request returned a successful response without image data, so the implementation should surface that case clearly and allow OpenClaw's configured fallback chain to proceed.

Metadata

Metadata

Assignees

No one assigned

    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