홈 블로그

How to Use the GLM 5.4 API

GLM 5.4 API blog cover

Dec 3, 2026

EmpirioLabs AI

고지: 이 글은 AI의 도움을 받아 작성되었으며 EmpirioLabs AI가 검토했습니다.

GLM 5.4 is available on EmpirioLabs. It is Z.ai's flagship model for coding and agentic work, released through its API on December 2, 2026. It reads text, images, video, and files such as PDFs, holds up to 1M tokens of context, writes up to 128K tokens, and always reasons before it answers.

Call it through an OpenAI-compatible API with function calling, built-in web search, JSON mode, and streaming. Try it in the Playground, read the parameters in the docs, and see the current rates on the GLM 5.4 model page.

요금

Usage based. One input rate and one output rate apply at every prompt size, and reasoning tokens bill as output tokens. Web search. Built-in web search adds a fee for each request that searches. Current rates are on the model page and the pricing page.

Quickstart

Point any OpenAI SDK at the EmpirioLabs base URL and pass glm-5-4 as the model. This example sends an image with a question and sets the reasoning level:

import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.empiriolabs.ai/v1",
    api_key=os.environ["EMPIRIOLABS_API_KEY"],
)

resp = client.chat.completions.create(
    model="glm-5-4",
    reasoning_effort="high",
    messages=[
        {"role": "user", "content": [
            {"type": "image_url", "image_url": {"url": "https://media.empiriolabs.ai/assets/og/og-home-v4.jpg"}},
            {"type": "text", "text": "What is this page advertising? Answer in one sentence, then write the HTML for a matching call-to-action button."},
        ]},
    ],
)

print(resp.choices[0].message.content)
print(resp.usage.prompt_tokens, "input tokens,", resp.usage.completion_tokens, "output tokens")

It printed a one-sentence summary of the page, the HTML and CSS for a matching button, and 1077 input tokens, 296 output tokens.

The same model ID works on /v1/responses, the Anthropic-shaped /v1/messages, and the Google-compatible /v1beta/models/glm-5-4:generateContent route.

Reasoning effort

GLM 5.4 always reasons. reasoning_effort takes low, high, or max; max is the default and is recommended for complex coding. A request for another level, or to turn thinking off, is served at the nearest supported level. The reasoning comes back in reasoning_content beside the answer, in a response and in a stream, and it bills as output tokens.

Images, video, and files

Send images as image_url parts and video as video_url parts, each as an https URL or a base64 data URL; a URL is recommended for video. Send a document such as a PDF as a file part with file_url or base64 file_data. One message can carry several images, and a file beside an image.

Multi-turn reasoning

By default the reasoning of earlier assistant turns is left out of the model's input. Set preserve_thinking to true to include it: return each turn's reasoning unchanged in that assistant message's reasoning_content field, and the earlier reasoning bills as input tokens. Reasoning between tool calls since the last user message is always kept.

Function calling and web search

Pass tools to let the model call your functions; it can call several in one turn, and tool_stream streams their arguments as they are written. Set tool_web_search to true and the model searches the web when it needs to, and ends its answer with a Sources list of the pages it used. count sets how many results a search returns (1 to 50), and search_recency_filter and search_domain_filter narrow them.

Things worth knowing before your first call

  • max_tokens covers reasoning and the answer together. A small cap can be spent on reasoning alone, which returns an empty answer with finish_reason length. Leave room above the reasoning you expect, or lower reasoning_effort for short replies.
  • The model decides when to call a function. tool_choice takes auto or none. A forced call (required or a named function) returns a 400, so ask for the call in your prompt.
  • Name the fields you want in JSON mode. {"type": "json_object"} returns valid JSON, and the prompt decides its keys, so list them. A JSON Schema in response_format is not enforced.
  • Send files by URL or as base64. A file_id returns a 400; use file_url or file_data instead.
  • The context window holds the prompt and the answer together. It is 1,048,576 tokens, and a longer request returns a 400 with the code context_length_exceeded.

GLM 5.4 is available now in the Playground and through the EmpirioLabs API.

더 나은 엔드포인트를 사용할 준비가 되셨나요?

저희 모델을 탐색하시거나, 비즈니스 문의, 맞춤형 배포 또는 기타 어떤 사항이든 문의해 주세요.