> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/deploy/supported-models/glm-ocr.md).

# GLM-OCR

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 Hosted API](/deploy/serverless-hosted-api-v2.md), [Dedicated Deployments](/deploy/dedicated-deployments.md), and [self-hosted Inference](https://inference.roboflow.com/).

## 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`](https://inference.roboflow.com/inference_helpers/inference_sdk/) wrapper.

{% tabs %}
{% tab title="HTTP (curl)" icon="webhook" %}
{% stepper %}
{% step %}

### Get your API Key

Create a Roboflow account, find your key on the [Roboflow API settings page](https://app.roboflow.com/settings/api) and make it available to your shell:

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}

### Run the model

Call the `/infer/lmm` endpoint with `curl`:

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

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="SDK (Python)" icon="python" %}
{% stepper %}
{% step %}

### Get your API Key

Create a Roboflow account, find your key on the [Roboflow API settings page](https://app.roboflow.com/settings/api) and make it available to your shell:

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}

### Install the dependencies

This package calls the model:

```bash
pip install inference-sdk
```

{% endstep %}

{% step %}

### Run the model

Run GLM-OCR on an image containing text:

```python
import os
import cv2
import numpy as np
import requests
from inference_sdk import InferenceHTTPClient

content = requests.get("https://media.roboflow.com/inference/license_plate_1.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

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
```

<figure><img src="/files/aziCp0jLbw0efgtbbD9G" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

## Inference speed

Latency measured with [Roboflow Inference](https://inference.roboflow.com/) 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.

<table data-search="false"><thead><tr><th>Alias</th><th>Latency, 128 tokens (ms)</th><th>Tokens/sec</th></tr></thead><tbody><tr><td><code>glm-ocr</code></td><td>1850</td><td>69</td></tr></tbody></table>

{% hint style="info" %}
Set `api_url` to match your deployment target:

* `https://serverless.roboflow.com` for the Serverless Hosted API.
* `http://localhost:9001` for a local [Inference](https://inference.roboflow.com/) server.
* Your [Dedicated Deployment](/deploy/dedicated-deployments.md) URL for a private endpoint.
  {% endhint %}
