Install
openclaw skills install free-ocr-zcExtract text from images via OpenRouter API using Baidu Qianfan OCR model, supporting URLs and local files with customizable prompts.
openclaw skills install free-ocr-zcThis 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.
When you need to extract text from an image:
Ensure prerequisites:
openai, requests (install via pip install openai requests)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 <image_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.
python ocr.py "https://example.com/image.jpg"
python ocr.py "https://example.com/image.jpg" "请识别图片中的所有文字"
python ocr.py "C:\path\to\image.jpg"
The skill uses the OpenAI client configured with:
https://openrouter.ai/api/v1baidu/qianfan-ocr-fast:free (configurable via environment variable)OPENROUTER_API_KEY environment variableIt sends a multimodal request containing:
The model returns the extracted text which is printed to console.
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)mkdir -p skills/openrouter-ocrocr.py script in this directorypip install openai requestssetx OPENROUTER_API_KEY "your_api_key_here"
(Restart terminal after setting)OCR_MODEL environment variableOPENROUTER_API_KEY is set correctlypip install openai requests✅ OCR 识别结果:
------------------------------------------------------------
这是识别出的文本内容
...
------------------------------------------------------------
Never commit your API key to version control. Keep it secure in environment variables.