Skip to content

图片链接和原样的 image_url / input_image 块转成 base64 交给 agy - #29

Merged
ifccod merged 1 commit into
mainfrom
feat/image-url
Nov 30, 2026
Merged

ifccod merged 1 commit into
mainfrom
feat/image-url

Conversation

@ifccod

@ifccod ifccod commented Nov 30, 2026

Copy link
Copy Markdown
Owner

agy 只收 base64 图片,上游对图片链接回 400。生产上 Sub2API 一个用户 24 小时有约 1 万条 400(a content block of type "image_url" is not supported,以及 an image source other than base64)。

改动(都在 Video (local patch) 里)

  • 图片链接(图片块的 url source,或 Magpie 原样留下的 image_url / input_image 块,url 是字符串或 {url}):下载后按文件头识别成 PNG/JPEG/GIF/WebP,转成 base64 image 块;识别成视频的照旧转 video 块;都不是的留给上游判断。
  • image_url 块里的 data: URL 直接解码成对应的块。
  • 下载沿用视频链接那套:只允许 http(s),内网/回环地址拒绝(AGY_BRIDGE_VIDEO_PRIVATE=1 放开),最多 100 MB、3 次跳转,缓存一小时。

测试

  • fork/patch-e2e.mjs 17/17;新用例在 AGY_BRIDGE_VIDEO=0 时失败。
  • 上游 bun test:失败项和上游快照相同(catalog、re2、usage、“config names the provider”、“a read longer than magpie waits”)。
  • 本机真机(Magpie 0.1.4315):图片链接走 chat 和 responses 都从 400 变成 200,答对内容;base64 200;169.254.169.254 链接 400。

🤖 Generated with Claude Code

…agy inline

agy takes images only as base64, and upstream refuses an image by URL. The
bridge now downloads an image link (same private-address guard, size cap and
cache as video links) and also converts the raw OpenAI image_url /
input_image part some /v1/responses requests reach the plugin with, which
upstream rejected as an unknown block type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ifccod
ifccod merged commit b978dd3 into main Nov 30, 2026
1 check passed
@ifccod
ifccod deleted the feat/image-url branch November 30, 2026 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant