dsh-anthropic-image-clamp
其他 活跃维护

dsh-anthropic-image-clamp

noahchalifour/dsh-anthropic-image-clamp

自动等比压缩Claude请求中的每张图像,将最长边限制在2000px以内,多图批量提交不再触碰接口上限。请求阶段静默处理,无需手动干预,兼顾画质与发送速度。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
JavaScript
主要语言
MIT
开源协议
6 KB
仓库大小
2 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:noahchalifour/dsh-anthropic-image-clamp
git clone https://github.com/noahchalifour/dsh-anthropic-image-clamp.git
git clone git@github.com:noahchalifour/dsh-anthropic-image-clamp.git
README.md main

dsh-anthropic-image-clamp

Stops this Claude error in DeepSeek Harness:

messages.N.content.M.image.source.base64.data: At least one of the image
dimensions exceed max allowed size for many-image requests: 2000 pixels

Cause. Anthropic allows up to 8000px per side, but a request carrying
more than 20 images is capped at 2000px per side. DSH normalizes attachments
to a 2048×2048 pixel budget (8192px long edge), so a phone screenshot such as
1080×2400 is stored as-is. Once a session's history holds more than 20 images,
every request fails.

Fix. This host plugin wraps fetch for api.anthropic.com/v1/messages
requests and downscales any inline base64 image whose longer side exceeds
maxDimension (default 2000). The results are deterministic and cached by
content hash, so re-sent history stays byte-identical and the prompt cache
still hits.

Install, then restart DSH:

dsh plugin --profile desktop add github:noahchalifour/dsh-anthropic-image-clamp

Config override (profile cordis.patch.yml):

- id: anthropic-image-clamp
  config: { maxDimension: 1568, hosts: [api.anthropic.com] }

Limitation: requests routed through a subscriptions-plugin HTTP proxy use
undici's own fetch and bypass the wrapper. No proxy is configured on this
machine.