image_ocr
Extract text from images using OCR technology. Convert image content into editable text by providing an image URL.
Instructions
Extract text from an image using OCR ($0.002)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | Image URL |
Implementation Reference
- index.js:50-79 (handler)The callTool function performs the actual HTTP request to the API, which is used by image_ocr via its endpoint '/image/ocr'.
async function callTool(endpoint, params) { const fetch = (await import('node-fetch')).default; const isGet = ['GET'].includes((TOOLS.find(t => t.endpoint === endpoint) || {}).method); const url = isGet ? `${BASE_URL}${endpoint}?${new URLSearchParams(params)}` : `${BASE_URL}${endpoint}`; const res = await fetch(url, { method: isGet ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}`, }, body: isGet ? undefined : JSON.stringify(params), }); const text = await res.text(); let data; try { data = JSON.parse(text); } catch { data = { raw: text }; } if (!res.ok) { if (res.status === 402) { throw new Error(`Insufficient credits. Add credits at https://iteratools.com. Cost: ${TOOLS.find(t=>t.endpoint===endpoint)?.price || 'see docs'}`); } throw new Error(`API error ${res.status}: ${text.substring(0, 200)}`); } return data; } - index.js:21-21 (registration)The definition and registration of the 'image_ocr' tool in the TOOLS configuration array.
{ name: 'image_ocr', description: 'Extract text from an image using OCR', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'Image URL' } }, required: ['url'] }, endpoint: '/image/ocr', price: '$0.002' },