Capabilities

OCR

OCR (optical character recognition) reads the text in an image and returns it as plain text. Reach for it on scanned documents, PDFs exported to images, screenshots, receipts, forms, or photographs of a page — anywhere the words live inside a picture rather than as selectable text.

Read text from an image

OCR models are vision models specialised for documents, so you call them the same way you call vision — send the image as an image_url content part on a chat message and ask for the text. The model returns the transcription as the message content.

from pendra import Pendra

client = Pendra()

response = client.chat.completions.create(
    model="glm-ocr",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Extract all text from this image."},
            {"type": "image_url",
             "image_url": {"url": "data:image/png;base64,iVBORw0..."}},
        ],
    }],
)
print(response.choices[0].message.content)
A scanned passage of text sent to the model
The image you send
Response

Magna Carta (Medieval Latin for "Great Charter"), sometimes spelled Magna Charta, is a royal charter of rights agreed to by King John of England at Runnymede, near Windsor, on 15 June 1215. First drafted by the Archbishop of Canterbury, Cardinal Stephen Langton, to make peace between the unpopular king and a group of rebel barons…

Choosing a model

OCR models advertise the ocr capability — for example glm-ocr. Browse the ones available to you at /models?type=ocr, or install one from the catalogue in the console. Because OCR models are also vision models, they can answer questions about a document as well as transcribe it — ask for a summary, a specific field, or the text in a particular language.

OCR uses the chat endpoint. For the full message and content-part schema, see the Chat completions API reference.