> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Vision

> Ask questions about images with GLM-5.3 Flash, sent inline as base64 data URIs.

[GLM-5.3 Flash](/docs/models.md) accept text and images in the same request. Instead of a plain string, the user message's `content` becomes an array of parts, `text` blocks and `image_url` blocks, with one rule that trips people up: **every image must be inlined as a base64 data URI**. The field is named `image_url` for OpenAI compatibility, but the inference engine does not fetch remote URLs.

```python Python theme={null}
import base64
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://inference.pearlresearch.ai/v1",
    api_key=os.environ.get("PEARL_API_KEY"),
)

# The endpoint accepts base64 data URIs, not remote URLs.
# Encode your image before sending it.
with open("receipt.png", "rb") as f:
    data_uri = f"data:image/png;base64,{base64.b64encode(f.read()).decode()}"

response = client.chat.completions.create(
    model="zai-org/GLM-5.3-Flash",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Extract the total amount and the date."},
                {"type": "image_url", "image_url": {"url": data_uri}},
            ],
        }
    ],
)

print(response.choices[0].message.content)
```

```typescript TypeScript theme={null}
import fs from 'node:fs';
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://inference.pearlresearch.ai/v1',
  apiKey: process.env.PEARL_API_KEY,
});

// The endpoint accepts base64 data URIs, not remote URLs.
// Encode your image before sending it.
const image = fs.readFileSync('receipt.png');
const dataUri = `data:image/png;base64,${image.toString('base64')}`;

const response = await client.chat.completions.create({
  model: 'zai-org/GLM-5.3-Flash',
  messages: [
    {
      role: 'user',
      content: [
        {type: 'text', text: 'Extract the total amount and the date.'},
        {type: 'image_url', image_url: {url: dataUri}},
      ],
    },
  ],
});

console.log(response.choices[0].message.content);
```

```bash cURL theme={null}
# Encode your image as a base64 data URI first.
DATA_URI="data:image/png;base64,$(base64 < receipt.png | tr -d '\n')"

curl https://inference.pearlresearch.ai/v1/chat/completions \
  -H "Authorization: Bearer $PEARL_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"model\": \"zai-org/GLM-5.3-Flash\",
    \"messages\": [
      {
        \"role\": \"user\",
        \"content\": [
          {\"type\": \"text\", \"text\": \"Extract the total amount and the date.\"},
          {\"type\": \"image_url\", \"image_url\": {\"url\": \"$DATA_URI\"}}
        ]
      }
    ]
  }"
```

> [!NOTE]
>
> A remote `https://…` URL in `image_url.url` is silently unresolvable at the inference engine and returns an upstream validation error. If your image lives at a URL, download it in your own code and encode the bytes as `data:image/<format>;base64,…` before sending.

## Getting good results

* Ask a specific question next to the image, "extract the total" beats "describe this" when you want a field, and pairs well with [JSON mode](/docs/json-mode.md) for machine-readable extraction.
* Images are tokenized into the prompt, so they count as input tokens (and base64 inflates the request body by \~33%), send the smallest image that is still legible; long documents usually work better cropped to the relevant region than downscaled whole.
* Vision input combines with the rest of the API surface, [streaming](/docs/streaming.md), tools, and JSON mode all work on multimodal requests.

> [!NOTE]
>
> GLM-5.3 Flash is the catalog's vision model today; text-only models reject image parts. Check `input_modalities` on `GET /models` before routing multimodal traffic.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.