cliproxy-media
Source: https://github.com/bencoremans/site/tree/main/skills/cliproxy-media
Analyze images and PDFs via CLIProxyAPI (Claude Max subscription, zero extra cost).
Setup
Set the endpoint to your CLIProxy instance:
CODEBLOCK0
For Docker setups, replace your-host with your container hostname (e.g. cliproxyapi, localhost, or the container IP).
Quick start
CODEBLOCK1
What works ✅ / What doesn't ❌
✅ Supported file types
| Type | Format | Note |
|---|
| Image | INLINECODE3 / INLINECODE4 | Requires valid JPEG data |
| Image |
.png | Fully supported |
| Image |
.gif | Fully supported |
| Image |
.webp | Fully supported |
| Document |
.pdf | Base64-encoded, via
document content type |
| Image via URL |
http:// /
https:// | Direct URL reference, no download needed |
Multiple files at once: Provide multiple paths before the question. Max ~100 per request (Anthropic limit).
❌ Not supported
- - Office files (
.docx, .xlsx, .pptx) — Workaround: convert to PDF - Audio (
.mp3, .wav, .ogg) — Use Whisper for transcription - Video (
.mp4, .mov, .avi) — Not supported by the model - Other document types (
.txt, .html, .md as document) — Send text directly as a string
⚠️ System prompt warning
CLIProxyAPI accepts only the array notation for system prompts. The string notation is silently ignored — the model does not see it, but you also won't get an error message!
CODEBLOCK2
The --system argument in analyze.py automatically uses the correct array notation.
Configuration (env vars)
| Variable | Default | Description |
|---|
| INLINECODE26 | INLINECODE27 | Full endpoint URL |
| INLINECODE28 |
claude-sonnet-4-6 | Model to use |
Example:
CODEBLOCK3
Additional options
CODEBLOCK4
Compatibility
This script works with any API that supports the Anthropic Messages format:
| Provider | Compatible | Note |
|---|
| CLIProxyAPI | ✅ Yes | Primarily tested, system prompt array required |
| OpenRouter |
✅ Yes | Use Bearer token instead of
x-api-key: dummy |
|
LiteLLM | ✅ Yes | As proxy for Anthropic format |
|
Anthropic direct | ✅ Yes | Use
ANTHROPIC_API_KEY as x-api-key |
Note for non-CLIProxy endpoints: Some proxies do accept string notation for system prompts. Always use array notation for maximum compatibility.
Known limitations of CLIProxyAPI
- -
temperature and top_p may not be used at the same time (HTTP 400) - PDF as document with URL source does not work (
Unable to download the file) - Only
claude-sonnet-4-6 and claude-opus-4-6 available (haiku is deprecated) - INLINECODE37 is always
not_available in the response
Direct Python API
If you want to call the script from your own Python code:
CODEBLOCK5
Or use the built-in exec tool:
CODEBLOCK6
cliproxy-media
来源: https://github.com/bencoremans/site/tree/main/skills/cliproxy-media
通过 CLIProxyAPI 分析图像和 PDF 文件(需 Claude Max 订阅,零额外费用)。
设置
将端点设置为你的 CLIProxy 实例:
bash
export CLIPROXY_URL=http://your-host:8317/v1/messages
对于 Docker 环境,将 your-host 替换为你的容器主机名(例如 cliproxyapi、localhost 或容器 IP)。
快速开始
bash
分析图像
python3 skills/cliproxy-media/scripts/analyze.py /path/to/image.jpg 这张图片里有什么?
读取 PDF
python3 skills/cliproxy-media/scripts/analyze.py /path/to/document.pdf 请给出摘要
比较多张图像
python3 skills/cliproxy-media/scripts/analyze.py img1.jpg img2.jpg 比较这些图像
使用流式输出(立即显示结果)
python3 skills/cliproxy-media/scripts/analyze.py --stream image.jpg 详细描述
使用系统提示词
python3 skills/cliproxy-media/scripts/analyze.py --system 你是一名医学专家 scan.jpg 你看到了什么?
使用更高的 token 限制
python3 skills/cliproxy-media/scripts/analyze.py --max-tokens 4096 document.pdf 进行详尽分析
支持的功能 ✅ / 不支持的功能 ❌
✅ 支持的文件类型
| 类型 | 格式 | 说明 |
|---|
| 图像 | .jpg / .jpeg | 需要有效的 JPEG 数据 |
| 图像 |
.png | 完全支持 |
| 图像 | .gif | 完全支持 |
| 图像 | .webp | 完全支持 |
| 文档 | .pdf | Base64 编码,通过 document 内容类型 |
| 通过 URL 的图像 | http:// / https:// | 直接引用 URL,无需下载 |
同时处理多个文件: 在问题前提供多个路径。每次请求最多约 100 个(Anthropic 限制)。
❌ 不支持的功能
- - Office 文件(.docx、.xlsx、.pptx)— 解决方法:转换为 PDF
- 音频(.mp3、.wav、.ogg)— 使用 Whisper 进行转录
- 视频(.mp4、.mov、.avi)— 模型不支持
- 其他文档类型(.txt、.html、.md 作为文档)— 直接以字符串形式发送文本
⚠️ 系统提示词警告
CLIProxyAPI 仅接受系统提示词的数组表示法。字符串表示法会被静默忽略——模型看不到它,但你也不会收到错误消息!
python
❌ 不起作用 — 被忽略且无错误消息
payload[system] = 你是一名专家。
✅ 有效 — 始终使用数组表示法
payload[system] = [{type: text, text: 你是一名专家。}]
analyze.py 中的 --system 参数会自动使用正确的数组表示法。
配置(环境变量)
| 变量 | 默认值 | 描述 |
|---|
| CLIPROXYURL | http://localhost:8317/v1/messages | 完整端点 URL |
| CLIPROXYMODEL |
claude-sonnet-4-6 | 使用的模型 |
示例:
bash
export CLIPROXY_URL=http://localhost:8317/v1/messages
export CLIPROXY_MODEL=claude-opus-4-6
python3 skills/cliproxy-media/scripts/analyze.py image.jpg 问题
附加选项
--stream 通过 SSE 流式输出(立即显示结果)
--system TEXT 系统提示词(自动以数组形式发送)
--max-tokens N 最大输出 token 数(默认:1024)
--model MODEL 模型覆盖(覆盖 CLIPROXY_MODEL)
--url URL 端点覆盖(覆盖 CLIPROXY_URL)
兼容性
此脚本适用于任何支持 Anthropic Messages 格式的 API:
| 提供商 | 兼容性 | 说明 |
|---|
| CLIProxyAPI | ✅ 是 | 主要测试对象,需要系统提示词数组 |
| OpenRouter |
✅ 是 | 使用 Bearer token 替代 x-api-key: dummy |
|
LiteLLM | ✅ 是 | 作为 Anthropic 格式的代理 |
|
Anthropic 直连 | ✅ 是 | 使用 ANTHROPIC
APIKEY 作为 x-api-key |
非 CLIProxy 端点说明: 某些代理确实接受字符串表示法的系统提示词。为获得最大兼容性,请始终使用数组表示法。
CLIProxyAPI 的已知限制
- - temperature 和 topp 不能同时使用(HTTP 400)
- 使用 URL 来源的 PDF 文档无法正常工作(无法下载文件)
- 仅提供 claude-sonnet-4-6 和 claude-opus-4-6(haiku 已弃用)
- 响应中的 inferencegeo 始终为 not_available
直接 Python API
如果你想从自己的 Python 代码中调用此脚本:
python
import subprocess, json
result = subprocess.run(
[python3, skills/cliproxy-media/scripts/analyze.py, image.jpg, 描述这张图片],
capture_output=True, text=True
)
print(result.stdout)
或者使用内置的 exec 工具:
exec: python3 skills/cliproxy-media/scripts/analyze.py /path/to/image.jpg 问题