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.

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.

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
  }'

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.

AliasLatency, 128 tokens (ms)Tokens/sec
glm-ocr185069

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.

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:9001

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:

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"])

Further reading