/install free-ocr-zc
OpenRouter OCR Skill
Overview
This skill provides OCR (Optical Character Recognition) functionality using models available via OpenRouter. It uses the OpenAI Python library to communicate with OpenRouter's API, specifically designed for models like Baidu's Qianfan OCR.
Quick Start
When you need to extract text from an image:
-
Ensure prerequisites:
- Python 3.x installed
- Required packages:
openai,requests(install viapip install openai requests) - Place your OpenRouter API key in the file:
C:\Users\Administrator\.openclaw\secrets\openrouter.env(format:OPENROUTER_API_KEY=your_key_here)
-
Call the OCR script with an image URL or local file path:
python ocr.py \x3Cimage_input> [prompt]image_input: Either a URL or a local file path to the imageprompt: Optional text prompt for the OCR (default: "OCR提取图片所有文字")
-
Get result: The script prints the extracted text to stdout.
Usage Examples
Basic Usage with Default Prompt
python ocr.py "https://example.com/image.jpg"
Custom Prompt
python ocr.py "https://example.com/image.jpg" "请识别图片中的所有文字"
Local Image File
python ocr.py "C:\path o\image.jpg"
How It Works
The skill uses the OpenAI client configured with:
- Base URL:
https://openrouter.ai/api/v1 - Model:
baidu/qianfan-ocr-fast:free(configurable via environment variable) - API Key: Read from
OPENROUTER_API_KEYenvironment variable
It sends a multimodal request containing:
- A text prompt (default: "OCR提取图片所有文字")
- The image (encoded as base64 if local, or passed directly if URL)
The model returns the extracted text which is printed to console.
Environment Variables
OPENROUTER_API_KEY: Required - Your OpenRouter API keyOCR_MODEL: Optional - Model to use (default:baidu/qianfan-ocr-fast:free)OCR_BASE_URL: Optional - OpenRouter base URL (default:https://openrouter.ai/api/v1)
Installation
- Create the skill directory:
mkdir -p skills/openrouter-ocr - Save the
ocr.pyscript in this directory - Install dependencies:
pip install openai requests - Set your OpenRouter API key:
(Restart terminal after setting)setx OPENROUTER_API_KEY "your_api_key_here"
Notes
- The skill works with both HTTP/HTTPS URLs and local file paths
- For local files, the image is read and base64-encoded before sending
- Error handling includes network issues, invalid API keys, and model errors
- The default model is Baidu's Qianfan OCR fast version (free tier)
- You can change the model by setting the
OCR_MODELenvironment variable - Response time depends on image size and model speed
Troubleshooting
- API Key Error: Ensure
OPENROUTER_API_KEYis set correctly - Module Not Found: Install required packages with
pip install openai requests - Image Access: Verify the image URL is accessible or local path exists
- Model Not Available: Check if the specified model is available on OpenRouter
Example Output
✅ OCR 识别结果:
------------------------------------------------------------
这是识别出的文本内容
...
------------------------------------------------------------
Security Note
Never commit your API key to version control. Keep it secure in environment variables.
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install free-ocr-zc - 安装完成后,直接呼叫该 Skill 的名称或使用
/free-ocr-zc触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
free-ocr-zc 是什么?
Extract text from images via OpenRouter API using Baidu Qianfan OCR model, supporting URLs and local files with customizable prompts. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 38 次。
如何安装 free-ocr-zc?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install free-ocr-zc」即可一键安装,无需额外配置。
free-ocr-zc 是免费的吗?
是的,free-ocr-zc 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
free-ocr-zc 支持哪些平台?
free-ocr-zc 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 free-ocr-zc?
由 张翀(@openclawzhangchong)开发并维护,当前版本 v1.0.3。