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.
GLM-OCR API
GLM-OCR runs through the shared /infer/lmm endpoint. Call it through the HTTP endpoint directly with curl, or with the inference-sdk wrapper.
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"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
}'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"Install the dependencies
This package calls the model:
pip install -U inference-sdk supervisionRun 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
GLM-OCR 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.comfor the Serverless Cloud API.http://localhost:9001for a local Inference server.- Your Dedicated Deployment URL for a private endpoint.
Run GLM-OCR with self-hosted Inference
GLM-OCR also runs on an Inference server you host yourself.
Self-hosted GLM-OCR requires a GPU and an Inference build with inference-models support enabled (USE_INFERENCE_MODELS=true).
Start a local server:
pip install inference-cli
inference server start # serves http://localhost:9001Then 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:
import os
from inference_sdk import InferenceHTTPClient
client = InferenceHTTPClient(
api_url="http://127.0.0.1:9001",
api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer_lmm(
inference_input="./serial_number.png",
prompt="Text Recognition:",
model_id="glm-ocr",
)
print(result["response"])