Convert GIF to plain text (OCR)
To convert GIF to plain text (OCR), send one POST to /v1/ocr-image-to-text with the GIF source. Each call costs $0.005 in USDC on Base via x402, with no account and no API key. The source file can be up to 10 MB.
- Endpoint
POST /v1/ocr-image-to-text- Price
- $0.005 per call
- Service
- ocr-image-to-text
01Limits
| Limit | Value |
|---|---|
| Largest source file | 10 MB (10,485,760 bytes) |
| Timeout | 45 s |
| Source formats | GIF, JPEG, PNG, TIFF, WebP |
| Output formats | plain text |
| Option lang | one of "eng"; default "eng" |
02Example
A real GIF to plain text run of ocr-image-to-text.
POST /v1/ocr-image-to-text
content-type: application/json
payment-signature: <base64 x402 payload>
{
"url": "https://grist.tools/samples/images/pair-note.gif",
"lang": "eng"
}200 OK
payment-response: <base64 settlement receipt>
{
"source_url": "https://grist.tools/samples/images/pair-note.gif",
"lang": "eng",
"image_format": "gif",
"text": "SAMPLE SCAN FOR OCR\nSECOND LINE 2026\n",
"confidence": 93
}Source file: images/pair-note.gif, 1.9 KB (1,937 bytes). Two-colour GIF of the same 556x100 raster as ocr-scan.png: two uppercase lines drawn from a hand-written 5x7 bitmap font, SAMPLE SCAN FOR OCR and SECOND LINE 2026. The request sets lang to "eng". The recorded run returned 37 bytes of plain text, 2% of the source size, with a mean OCR confidence of 93 and language eng.
In the sample itself, the GIF89a header declares a logical screen of 556 by 100 pixels with a global colour table of 2 entries, and the file holds 1 image. The returned text runs to 3 lines, 1 blank one among them, and its longest line, "SAMPLE SCAN FOR OCR", holds 19 characters. Its first line reads "SAMPLE SCAN FOR OCR" and its last "SECOND LINE 2026". Split on whitespace, it yields 7 tokens over 2 non-blank lines.
03Format notes
GIF as a source
Each GIF frame takes its colours from a palette of at most 256 entries, and transparency is a single palette index rather than a graded alpha channel. image-convert recognises the format by the ASCII header GIF87a or GIF89a, whereas the OCR detector accepts any file opening with the four bytes GIF8. Animation does not survive image-convert: sharp opens the input with animated decoding off, so the first frame is transcoded and later frames are ignored, and the pixel budget is checked against that frame's header dimensions. GIF is missing from the encoder's output enum, so these pages read GIF but never write it. When text is the goal, ocr-image-to-text passes the same bytes to the offline Tesseract engine after its signature check and returns the recognised lines together with a mean confidence score for the page.
plain text as a target
Plain text is recovered in several ways, each tied to one reader. ocr-image-to-text reads pixels with Tesseract running offline from local files, returns a mean confidence with the text, and offers only the languages whose data ships with the service. pdf-to-text returns the existing text layer page by page and performs no OCR. epub-to-text follows the spine's reading order and adds title, creator and language metadata. pptx-to-text returns slide body text in slide order, leaving out speaker notes. html-clean-text extracts article text with Readability by default and returns Markdown in the same response. Because each reader works differently, the text reflects its source: recognised characters with a confidence score from an image, but characters already present in the file from documents and pages.
04Errors
| Code | HTTP |
|---|---|
invalid_input | 400 |
blocked_target | 403 |
unreachable_target | 424 |
upstream_timeout | 424 |
unsupported_content_type | 415 |
too_large | 413 |
unprocessable | 422 |
internal | 500 |
When each is raised, and what it means for payment: /docs/ocr-image-to-text.
05Questions
- What does it cost to convert GIF to plain text?
- $0.005 per call, paid in USDC on Base via x402.
- How large can the GIF file be?
- Up to 10 MB (10,485,760 bytes). Past a limit the call answers too_large (413).
- What happens if the conversion fails?
- The tool answers with a typed JSON error from the errors table. Payment is settled only after the tool has produced its result; a call that fails inside the tool is never settled.