free-ocr-zc

# OpenRouter OCR Skill

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "free-ocr-zc" with this command: npx skills add openclawzhangchong/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:

  1. Ensure prerequisites:

    • Python 3.x installed
    • Required packages: openai, requests (install via pip 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)
  2. 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 image
    • prompt: Optional text prompt for the OCR (default: "OCR提取图片所有文字")
  3. 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\to\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_KEY environment variable

It sends a multimodal request containing:

  1. A text prompt (default: "OCR提取图片所有文字")
  2. 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 key
  • OCR_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

  1. Create the skill directory: mkdir -p skills/openrouter-ocr
  2. Save the ocr.py script in this directory
  3. Install dependencies: pip install openai requests
  4. Set your OpenRouter API key:
    setx OPENROUTER_API_KEY "your_api_key_here"
    
    (Restart terminal after setting)

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_MODEL environment variable
  • Response time depends on image size and model speed

Troubleshooting

  • API Key Error: Ensure OPENROUTER_API_KEY is 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.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Civic

Connect to Civic MCP for 100+ integrations.

Registry SourceRecently Updated
General

X402 X Tweet Fetcher

Buy Xcatcher points via x402 on Solana USDC, obtain an API key, create X crawl tasks, poll status, and download XLSX results.

Registry SourceRecently Updated
General

TencentCloud YT Segment Portrait

Binary classification-based human portrait segmentation for complete body contour recognition and image matting.

Registry SourceRecently Updated
General

ksdsl-skilll

Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Clau...

Registry SourceRecently Updated
3820f1zzyw