For the complete documentation index, see llms.txt. This page is also available as Markdown.

GLM-OCR

Use GLM-OCR for image OCR through our Serverless Cloud API

GLM-OCR is an OCR model based on the GLM vision-language model family. It transcribes text from an image and is well-suited for documents, signs, and labels with mixed layouts. We support GLM-OCR through our Serverless Cloud API, Dedicated Deployments, and self-hosted Inference.

Code sample

GLM-OCR runs through the shared /infer/lmm endpoint. Call it through the HTTP endpoint directly with curl, or with the inference-sdk wrapper.

1

Get your API Key

Create a Roboflow account, find your key on the Roboflow API settings page and make it available to your shell:

export ROBOFLOW_API_KEY="your-key-here"
2

Run the model

Call the /infer/lmm endpoint with curl:

curl --location 'https://serverless.roboflow.com/infer/lmm' \
  --header 'Content-Type: application/json' \
  --data '{
    "api_key": "'"$ROBOFLOW_API_KEY"'",
    "image": {"type": "url", "value": "https://media.roboflow.com/inference/license_plate_1.jpg"},
    "model_id": "glm-ocr",
    "prompt": "OCR",
    "max_new_tokens": 128
  }'
1

Get your API Key

Create a Roboflow account, find your key on the Roboflow API settings page and make it available to your shell:

export ROBOFLOW_API_KEY="your-key-here"
2

Install the dependencies

This package calls the model:

pip install -U inference-sdk supervision
3

Run the model

Run GLM-OCR on an image containing text:

import os
import supervision as sv
from inference_sdk import InferenceHTTPClient

image = sv.load_image_from_url("https://media.roboflow.com/inference/license_plate_1.jpg")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer_lmm(
    image,
    model_id="glm-ocr",
    prompt="OCR",
    max_new_tokens=128,
)
print(result["response"])

The code above prints the recognized text to the terminal:

280 SE
AUTOMATIC
34 T 6511

Inference speed

Latency measured with Roboflow Inference on 1x NVIDIA L4, batch size 1, generating exactly 128 tokens with greedy decoding from a fixed prompt. Latency scales with output length, so use tokens/sec to estimate other lengths.

Alias
Latency, 128 tokens (ms)
Tokens/sec

glm-ocr

1850

69

Set api_url to match your deployment target:

  • https://serverless.roboflow.com for the Serverless Cloud API.

  • http://localhost:9001 for a local Inference server.

  • Your Dedicated Deployment URL for a private endpoint.

Use with Inference (self-hosted)

GLM-OCR also runs on an Inference server you host yourself.

Start a local server:

Then call the shared multimodal endpoint with a recognition prompt. GLM-OCR accepts custom prompts, so you can steer it toward serial numbers, labels, or document text:

Further reading

Last updated

Was this helpful?