Skip to content

Gemini 生图结果通过 /v1/chat/completions 返回 base64 文本,导致 OpenWebUI 兼容性问题与流式响应超长报错 #102

Open

Description

@Simon9052

当 Gemini 成功生成图片后,WebAI2API 看起来已经成功获取到了图片,但最终在 /v1/chat/completions 的响应中,会把图片作为一个巨大的 data URI 字符串直接放进 message.content 或 delta.content 中返回。

这会导致 OpenWebUI 出现两类问题:

stream: true 时 OpenWebUI 端返回 400,错误类似:
Got more than 131072 bytes when reading: b’data: {“id”:"chatcmpl-…’

看起来是因为服务端把整张图片的 data:image/…;base64,… 放进了单个 SSE chunk 中,导致单条流式事件过大。

stream: false 时 请求虽然能成功返回,但 OpenWebUI 会直接把一整串 base64 文本显示在聊天窗口里,而不是显示图片。
实际观察到的现象

Gemini 生图本身是成功的。 在日志中可以看到类似下面的图片预览链接:

https://lh3.googleusercontent.com/…

但直接在外部浏览器访问这个链接时,会显示:

Your client does not have permission to get URL

Image

Activity

  1. kuiyr0810 commented on May 12, 2026

    @kuiyr0810

    生图好像都有这个问题,返回的base64文本直接导致窗口卡死,想转md都不行

  2. RyanRaw commented on May 13, 2026

    @RyanRaw

    生图好像都有这个问题,返回的base64文本直接导致窗口卡死,想转md都不行

    系统设置-服务器里有“图片 Markdown 格式”

  3. kuiyr0810 commented on May 14, 2026

    @kuiyr0810

    生图好像都有这个问题,返回的base64文本直接导致窗口卡死,想转md都不行

    系统设置-服务器里有“图片 Markdown 格式”

    我有时间了改下代码试试,自己写的不太兼容图片的显示

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions