Skip to main content

Function

Tool identifier ocr. ocr uses the configured vision model to transcribe the text visible in an image verbatim, without translating or summarizing; an image without text returns an empty string. The image can be a local path or a publicly accessible http(s) URL. The tool is an async function (async def) and shares its model configuration, API key, and size limits with image_understand. Import path: from veadk.tools.builtin_tools.ocr import ocr

Prerequisites

Requirement: configure the API key for the agent’s reasoning model; the selected model must support vision understanding.
Environment variables:
  • MODEL_AGENT_API_KEY: API key used for the vision request; falls back to model.api_key in the configuration file when unset
  • MODEL_VISION_NAME: optional vision model name; the agent model name is used when unset
  • The endpoint is taken from model.api_base in the configuration file
Model-name resolution order is the model_name argument, then the MODEL_VISION_NAME environment variable, then the agent model name.

Usage

examples/tools/ocr/agent.py
Direct calls:

Parameters

Success returns {"text": ..., "language": ..., "model": ...}; language echoes the value passed in and model is the model actually used. On failure it returns {"error": ...}.

Notes

  • Local images must not exceed 20 MB; remote URLs pass an SSRF check before being forwarded to the model, so private and loopback addresses are blocked, and the model service fetches them over the public network.
  • language is only a hint: it neither restricts the model output nor represents the detected language. For scene description or questions about an image, use image_understand.
  • document_parse only extracts embedded text from scanned PDFs and does not run OCR; convert PDF pages to images first and then use this tool.
Last modified on November 20, 2026