GLM 5.4 Vision: Send Images, Video and Files via API
Dec 3, 2026

GLM 5.4 Vision: Send Images, Video and Files via API

How GLM 5.4 vision works in the API: image_url, video_url and file blocks, size and format limits, code examples, cost math and fixes for common errors.

Quick answer: GLM 5.4 vision is built into the main glm-5.4 model, with no separate "V" model. Send a messages[].content array with a text block plus one or more media blocks: image_url (jpg/png, under 5 MB, up to 6000×6000 px, URL or Base64), video_url (mp4/mkv/mov, up to 200 MB) or file (up to 50 MB, by file_id, file_url or file_data). A file block cannot be mixed with image or video blocks in the same message. Pricing is the normal GLM 5.4 rate: $1.40 input and $4.40 output per million tokens.

GLM 5.4 is the first GLM flagship that can see. GLM 5.3 was text-only and only the Flash tier read images, so teams that wanted a flagship model on screenshots had to chain a vision model in front of it. Z.ai's GLM-5.4 page covers image input in a short paragraph; the size, format and mixing rules sit in the Chat Completions reference. This guide collects the GLM 5.4 vision rules in one place, with code you can paste, checked against Z.ai's docs on December 3, 2026.

The problem GLM 5.4 vision solves

The usual pain is a two-model pipeline: OCR or a captioning model turns an image into text, then a reasoning model works on that text, and details get lost in between. A layout bug, a chart axis or a CAD dimension rarely survives the caption. GLM 5.4 vision lets the same model that writes the code look at the source. Z.ai's launch demos lean on that: code written from video frames, a FreeCAD robotic arm and GLSL 3D scenes. Those are Z.ai's picks, not measured success rates, but they show where GLM 5.4 vision is aimed.

GLM 5.4 vision input limits

InputBlock typeFormatsLimitHow to pass it
Imageimage_urljpg, jpeg, pngUnder 5 MB, max 6000×6000 pxURL (recommended) or Base64 data URL
Videovideo_urlmp4, mkv, movUp to 200 MBURL
FilefileDocumentsUp to 50 MBOne of file_id, file_url, file_data
Texttext—Within 1M contextPlain string

GLM 5.4 vision rules worth remembering:

  • Content arrays are limited to the GLM-5.4 and GLM-5.3-Flash series. Sending an array to glm-5.2 will not work.
  • For several images, add several image_url blocks.
  • A file block cannot be combined with image_url or video_url blocks.
  • Output is always text. GLM 5.4 vision reads media; it does not generate images.

Step 1: Send an image to GLM 5.4 vision

The smallest working GLM 5.4 vision request is one text block and one image block:

import os
from openai import OpenAI

client = OpenAI(base_url="https://api.z.ai/api/paas/v4",
                api_key=os.environ["ZAI_API_KEY"])

resp = client.chat.completions.create(
    model="glm-5.4",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Rebuild this mockup as a React + Tailwind component."},
            {"type": "image_url", "image_url": {"url": "https://example.com/mockup.png"}},
        ],
    }],
    max_tokens=16000,
)
print(resp.choices[0].message.content)

Z.ai recommends URLs over Base64. A URL keeps the request small; Base64 inflates payload size by about a third and makes logs heavy. Use a data URL such as data:image/png;base64,... only when the image cannot be hosted.

Step 2: Send a video

GLM 5.4 vision accepts video through a video_url block:

{
  "model": "glm-5.4",
  "messages": [{
    "role": "user",
    "content": [
      { "type": "text", "text": "List every UI error shown in this screen recording, with timestamps." },
      { "type": "video_url", "video_url": { "url": "https://example.com/bug-repro.mp4" } }
    ]
  }]
}

Trim recordings to the part that matters before you send them. Z.ai has not published how GLM 5.4 vision samples frames or how many tokens a minute of video costs, so measure usage.prompt_tokens on a short clip first.

Step 3: Send a document to GLM 5.4 vision

For PDFs and other files, use a file block with exactly one source:

{ "type": "file", "file": { "file_url": "https://example.com/spec.pdf", "filename": "spec.pdf" } }

file_data takes the form data:<MIME>;base64,<DATA>. Z.ai marks the older standalone file_url content type as still working but not recommended for new code.

Want to try GLM 5.4 vision before writing any code? Upload a screenshot to GLM 5.4 in glm5.app chat; the model picker shows GLM 5.4 as able to read images.

What GLM 5.4 vision is good for

Based on Z.ai's positioning and the model's coding focus, these are the jobs where GLM 5.4 vision earns its flagship price:

TaskWhy GLM 5.4 vision fits
Screenshot or Figma export to codeSees layout and writes code in one pass
Debugging from screen recordingsReads the failing state directly
Charts and dashboards to data or SQLKeeps axis and legend context
Diagrams and CAD views to scriptsMatches Z.ai's FreeCAD and 3D demos
Long PDFs with figures1M context holds text plus attachments

For bulk captioning, alt text or simple OCR, GLM 5.3 Flash uses the same block format at $0.15 / $0.50 per million tokens, about nine times less. Our GLM 5.4 vs GLM 5.3 Flash comparison covers that routing choice.

GLM 5.4 vision cost

Media is billed as input tokens at the normal GLM 5.4 rate. Z.ai does not publish a per-image token formula, so the only reliable number is the usage field in your own responses. A practical way to budget GLM 5.4 vision:

  1. Send five representative images and record usage.prompt_tokens.
  2. Subtract the tokens of a text-only version of the same prompt.
  3. Multiply the per-image tokens by $1.40 per million, plus output at $4.40 per million.

Remember that GLM 5.4 always thinks, and reasoning bills as output. Set max_tokens so a hard screenshot does not trigger an expensive "marathon thinking" pass.

Troubleshooting GLM 5.4 vision requests

Error or symptomLikely causeFix
Request rejectedImage over 5 MB or over 6000×6000 pxResize or recompress
Format errorWebP, GIF or HEIC imageConvert to png or jpg
Content array rejectedWrong model, such as glm-5.2Use glm-5.4 or glm-5.3-flash
File plus image rejectedMixed file and image_url blocksSplit into separate messages
Model ignores the imageURL not publicly reachableUse a public URL or Base64
Answer cut shortReasoning used up max_tokensRaise the limit

Using GLM 5.4 vision through glm5.app

glm5.app is an independent service, not run by Z.ai. It serves glm-5.4 in chat with image upload and through an OpenAI-compatible API on prepaid credits. See the API docs for the endpoint and the pricing page for credit rates. For high-volume GLM 5.4 vision jobs, going direct to Z.ai is cheaper per token.

FAQs

Does GLM 5.4 support vision?

Yes. GLM 5.4 vision accepts images, video and files as input and returns text.

What image formats does GLM 5.4 vision accept?

jpg, jpeg and png, each under 5 MB and at most 6000×6000 pixels.

Can GLM 5.4 vision read video?

Yes, through video_url blocks with mp4, mkv or mov files up to 200 MB.

Can GLM 5.4 generate images?

No. GLM 5.4 vision is input only; output is text.

Is there a cheaper model with the GLM 5.4 vision format?

GLM 5.3 Flash uses the same content blocks at about one-ninth of the price.

Final take

GLM 5.4 vision removes the caption step between seeing and coding. Keep images in png or jpg under 5 MB, never mix file and image blocks, and cap max_tokens. Then test it on the screenshots your team actually ships. Open the GLM 5.4 page for access options, or start a GLM 5.4 chat and drop in an image.

Sources

Checked December 3, 2026 against Z.ai's docs.

Start Using GLM 5 Today

Try GLM 5 free — reasoning, coding, agents, and image generation in one platform.