openclaw - 💡(How to fix) Fix [Bug]: Gemini image generation fails [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#61828Fetched 2026-04-08 02:53:54
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
labeled ×2

After upgrading to the latest version of openclaw today, the Gemini image generation no longer works. Calling Gemini for text generation works fine (my day-to-day model is Kimi 2.5), but the image generation doesn’t work with the same API key. This was not the case on my past release.

The exact error from Google:

HTTP 400

{
  "error": {
    "code": 400,
    "message": "API key expired. Please renew the API key.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_INVALID",
        "domain": "googleapis.com",
        "metadata": {
          "service": "generativelanguage.googleapis.com"
        }
      }
    ]
  }
}

Same error every time, even with fresh keys. Text generation works fine with the same key. Only image generation fails.

Snapshot from openclaw.json:

  "agents": {
    "defaults": {
"model": {
"primary": "moonshot/kimi-k2.5",
"fallbacks": [
"openai/gpt-5.4",
"openai/gpt-5.4-mini",
"openai/gpt-5.4-nano",
"google/gemini-3.1-pro-preview",
"google/gemini-3.1-flash-lite-preview"
]
},
"imageGenerationModel": {
"primary": "google/gemini-3.1-flash-image-preview"
},
"models": {
"openai/gpt-5.4": {},
"openai/gpt-5.4-mini": {},
"openai/gpt-5.4-nano": {},
"google/gemini-3.1-pro-preview": {},
"google/gemini-3.1-flash-lite-preview": {},
"moonshot/kimi-k2.5": {
"alias": "Kimi"
}
},
"workspace": "/home/hestebot/.openclaw/workspace",
"compaction": {
"mode": "safeguard"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
}
    }
  },

Error Message

The exact error from Google: "error": { Same error every time, even with fresh keys. Text generation works fine with the same key. Only image generation fails.

Root Cause

After upgrading to the latest version of openclaw today, the Gemini image generation no longer works. Calling Gemini for text generation works fine (my day-to-day model is Kimi 2.5), but the image generation doesn’t work with the same API key. This was not the case on my past release.

The exact error from Google:

HTTP 400

{
  "error": {
    "code": 400,
    "message": "API key expired. Please renew the API key.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_INVALID",
        "domain": "googleapis.com",
        "metadata": {
          "service": "generativelanguage.googleapis.com"
        }
      }
    ]
  }
}

Same error every time, even with fresh keys. Text generation works fine with the same key. Only image generation fails.

Snapshot from openclaw.json:

  "agents": {
    "defaults": {
"model": {
"primary": "moonshot/kimi-k2.5",
"fallbacks": [
"openai/gpt-5.4",
"openai/gpt-5.4-mini",
"openai/gpt-5.4-nano",
"google/gemini-3.1-pro-preview",
"google/gemini-3.1-flash-lite-preview"
]
},
"imageGenerationModel": {
"primary": "google/gemini-3.1-flash-image-preview"
},
"models": {
"openai/gpt-5.4": {},
"openai/gpt-5.4-mini": {},
"openai/gpt-5.4-nano": {},
"google/gemini-3.1-pro-preview": {},
"google/gemini-3.1-flash-lite-preview": {},
"moonshot/kimi-k2.5": {
"alias": "Kimi"
}
},
"workspace": "/home/hestebot/.openclaw/workspace",
"compaction": {
"mode": "safeguard"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
}
    }
  },

Fix Action

Fix / Workaround

  1. Upgrade to 🦞 OpenClaw 2026.4.5 (3e72c03)
  2. Ask OpenClaw to generate an image via Telegram
  3. Image generation fails with the above

Code Example

{
  "error": {
    "code": 400,
    "message": "API key expired. Please renew the API key.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_INVALID",
        "domain": "googleapis.com",
        "metadata": {
          "service": "generativelanguage.googleapis.com"
        }
      }
    ]
  }
}

---

"agents": {
    "defaults": {
"model": {
"primary": "moonshot/kimi-k2.5",
"fallbacks": [
"openai/gpt-5.4",
"openai/gpt-5.4-mini",
"openai/gpt-5.4-nano",
"google/gemini-3.1-pro-preview",
"google/gemini-3.1-flash-lite-preview"
]
},
"imageGenerationModel": {
"primary": "google/gemini-3.1-flash-image-preview"
},
"models": {
"openai/gpt-5.4": {},
"openai/gpt-5.4-mini": {},
"openai/gpt-5.4-nano": {},
"google/gemini-3.1-pro-preview": {},
"google/gemini-3.1-flash-lite-preview": {},
"moonshot/kimi-k2.5": {
"alias": "Kimi"
}
},
"workspace": "/home/hestebot/.openclaw/workspace",
"compaction": {
"mode": "safeguard"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
}
    }
  },

---
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

After upgrading to the latest version of openclaw today, the Gemini image generation no longer works. Calling Gemini for text generation works fine (my day-to-day model is Kimi 2.5), but the image generation doesn’t work with the same API key. This was not the case on my past release.

The exact error from Google:

HTTP 400

{
  "error": {
    "code": 400,
    "message": "API key expired. Please renew the API key.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_INVALID",
        "domain": "googleapis.com",
        "metadata": {
          "service": "generativelanguage.googleapis.com"
        }
      }
    ]
  }
}

Same error every time, even with fresh keys. Text generation works fine with the same key. Only image generation fails.

Snapshot from openclaw.json:

  "agents": {
    "defaults": {
"model": {
"primary": "moonshot/kimi-k2.5",
"fallbacks": [
"openai/gpt-5.4",
"openai/gpt-5.4-mini",
"openai/gpt-5.4-nano",
"google/gemini-3.1-pro-preview",
"google/gemini-3.1-flash-lite-preview"
]
},
"imageGenerationModel": {
"primary": "google/gemini-3.1-flash-image-preview"
},
"models": {
"openai/gpt-5.4": {},
"openai/gpt-5.4-mini": {},
"openai/gpt-5.4-nano": {},
"google/gemini-3.1-pro-preview": {},
"google/gemini-3.1-flash-lite-preview": {},
"moonshot/kimi-k2.5": {
"alias": "Kimi"
}
},
"workspace": "/home/hestebot/.openclaw/workspace",
"compaction": {
"mode": "safeguard"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
}
    }
  },

Steps to reproduce

  1. Upgrade to 🦞 OpenClaw 2026.4.5 (3e72c03)
  2. Ask OpenClaw to generate an image via Telegram
  3. Image generation fails with the above

Expected behavior

Image should be generated.

Actual behavior

OpenClaw cannot generate the image (see above HTTP API return).

OpenClaw version

OpenClaw 2026.4.5 (3e72c03)

Operating system

Linux openclaw5 6.17.0-20-generic #20-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 20:07:29 UTC 2026 x86_64 GNU/Linux

Install method

curl using the .sh script on the web site

Model

google/gemini-3.1-flash-image-preview

Provider / routing chain

Direct to model

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The issue is likely due to an invalid or expired API key being used for image generation with the Gemini model, despite the same key working for text generation.

Guidance

  • Verify that the API key is valid and not expired by checking the Google Cloud Console or the API key management dashboard.
  • Ensure that the API key has the necessary permissions and access to the Gemini image generation model.
  • Try regenerating a new API key and updating the openclaw.json configuration file with the new key to see if it resolves the issue.
  • Check the openclaw.json file for any configuration discrepancies between text and image generation models.

Example

No code snippet is provided as the issue seems to be related to API key configuration rather than code.

Notes

The issue may be specific to the Gemini image generation model or the OpenClaw version being used. Further investigation into the API key configuration and permissions may be necessary to resolve the issue.

Recommendation

Apply workaround: Regenerate a new API key and update the openclaw.json configuration file with the new key to see if it resolves the issue. This is a safe and straightforward step to take before exploring more complex solutions.

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…

FAQ

Expected behavior

Image should be generated.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING