DEV Community

Cover image for How to Use the GLM-5.3 API?
Hassann
Hassann

Posted on Originally published at apidog.com

How to Use the GLM-5.3 API?

Zhipu AI, the Chinese lab that operates internationally as Z.ai, released GLM-5.3 on August 14, 2026. Its internal evaluations report a 50% coding-capability improvement over GLM-5.2, with Terminal-Bench 3.0 rising from 4.6 to 28.3. Zhipu describes coding and agent capability as “approaching Claude Fable 5,” according to the BigGo launch report. Open weights are expected about two weeks later. For benchmarks and capability details, see what GLM-5.3 is; this post focuses on getting the API working.

Try Apidog today

This quickstart covers getting an API key, making a cURL request, using Python and Node.js through the OpenAI SDK, streaming output, tuning core parameters, and testing requests in Apidog before wiring them into your application.

The API is OpenAI-compatible. If you already use OpenAI-style chat completions, you primarily need to change the base URL, API key, and model ID.

GLM-5.3 launched recently, so verify model IDs, pricing, and limits against the live Z.ai documentation before deploying.

TL;DR

  • GLM-5.3 was released on August 14, 2026. Zhipu reports a 50% coding improvement over GLM-5.2 and a Terminal-Bench 3.0 increase from 4.6 to 28.3.
  • International endpoint: POST https://api.z.ai/api/paas/v4/chat/completions
  • Mainland China endpoint: POST https://open.bigmodel.cn/api/paas/v4/chat/completions
  • Authenticate with Authorization: Bearer $GLM_API_KEY.
  • The GLM-5 docs listed glm-5 at launch. The expected GLM-5.3 ID is glm-5.3, but confirm before hardcoding it.
  • Test request shapes, regional endpoints, model variables, and reasoning settings in Apidog before writing production code.

Why GLM-5.3 matters

GLM-5.3 is a post-training update on the GLM-5 base model. Zhipu reports that Terminal-Bench 3.0 increased from 4.6 to 28.3, while SWE-Marathon roughly doubled compared with GLM-5.2.

Treat these as vendor-reported results until independently reproduced. For API evaluation, the practical takeaway is simple: test GLM-5.3 on your own coding, shell, agent, and debugging prompts.

GLM-5.3 benchmark results

The GLM-5 family uses a Mixture of Experts architecture with 744B total parameters, about 40B active parameters per forward pass, and a 200K-token context window, according to Z.ai’s docs. These are GLM-5 family specifications, not necessarily GLM-5.3-specific changes.

Zhipu says it plans to release GLM-5.3 open weights around August 28, 2026, according to Pandaily’s launch coverage. If self-hosting is on your roadmap, use the hosted API now to create a prompt and response regression suite. See the GLM-5.3 self-hosting prep guide for that workflow.

Get an API key

Zhipu operates separate international and mainland China platforms.

Z.ai: international platform

  1. Sign up at z.ai.
  2. Open the API console.
  3. Create an API key.
  4. Use the documentation at docs.z.ai.

This guide defaults to the international endpoint.

Bigmodel.cn: mainland China platform

For mainland China traffic, use open.bigmodel.cn. The request format and authentication scheme are the same, but the hostname and billing are separate.

Store the key in an environment variable:

export GLM_API_KEY="your-key-from-the-console"
Enter fullscreen mode Exit fullscreen mode

Do not commit the key to source control. Add .env files to .gitignore, and use your deployment platform’s secret store in production.

Endpoint and authentication

Use the chat completions endpoint.

International:

POST https://api.z.ai/api/paas/v4/chat/completions
Enter fullscreen mode Exit fullscreen mode

Mainland China:

POST https://open.bigmodel.cn/api/paas/v4/chat/completions
Enter fullscreen mode Exit fullscreen mode

Send your key in the Authorization header:

Authorization: Bearer $GLM_API_KEY
Enter fullscreen mode Exit fullscreen mode

The request and response formats follow the OpenAI chat completions pattern:

  • Request fields include model and messages.
  • Responses include choices, message, finish_reason, and usage.
  • OpenAI Python and Node.js SDKs work after changing the provider base URL.

If you have an existing OpenAI-compatible integration, this is usually a configuration change rather than a rewrite. The same migration pattern applies to DeepSeek V4 Pro’s API.

Keep the model ID configurable

At launch, Z.ai documentation listed glm-5 on the GLM-5 page. Since Zhipu lists glm-5.2 and glm-5.1 separately on its pricing page, glm-5.3 is the expected model ID.

Use an environment variable rather than hardcoding it:

export GLM_MODEL="glm-5.3"
Enter fullscreen mode Exit fullscreen mode

If glm-5.3 is unavailable in your region, confirm the current ID in the GLM-5 docs and use the documented model name.

Your first request with cURL

Create a minimal smoke test before integrating an SDK:

curl "https://api.z.ai/api/paas/v4/chat/completions" \
  -H "Authorization: Bearer $GLM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3",
    "messages": [
      {
        "role": "system",
        "content": "You are a code reviewer. Flag issues as blocking or non-blocking."
      },
      {
        "role": "user",
        "content": "Review this shell script for safety:\n\nrm -rf $BUILD_DIR/*\ncp dist/* $DEPLOY_TARGET"
      }
    ],
    "temperature": 0.3,
    "max_tokens": 1024
  }'
Enter fullscreen mode Exit fullscreen mode

Read the generated content from:

choices[0].message.content
Enter fullscreen mode Exit fullscreen mode

Track token usage from:

usage.prompt_tokens
usage.completion_tokens
Enter fullscreen mode Exit fullscreen mode

For multi-step coding or agent tasks, enable the documented reasoning mode:

"thinking": {
  "type": "enabled"
}
Enter fullscreen mode Exit fullscreen mode

Use thinking for tasks that benefit from planning or deeper analysis. Skip it for simple classification, extraction, or short transformations where extra reasoning is unnecessary.

Python quickstart

Install the OpenAI SDK:

pip install --upgrade openai
Enter fullscreen mode Exit fullscreen mode

Then point the client at Z.ai:

import os
from openai import OpenAI

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

response = client.chat.completions.create(
    model=os.environ.get("GLM_MODEL", "glm-5.3"),
    messages=[
        {
            "role": "system",
            "content": "You are a code reviewer. Flag issues as blocking or non-blocking.",
        },
        {
            "role": "user",
            "content": (
                "Review this Flask route for security issues:\n\n"
                "@app.route('/user/<id>')\n"
                "def get_user(id):\n"
                "    return db.execute(f'SELECT * FROM users WHERE id = {id}')"
            ),
        },
    ],
    temperature=0.3,
    max_tokens=2048,
)

print(response.choices[0].message.content)
print("input tokens:", response.usage.prompt_tokens)
print("output tokens:", response.usage.completion_tokens)
Enter fullscreen mode Exit fullscreen mode

Log usage from the first day of testing. Until GLM-5.3-specific pricing is published, token counts are your best input for cost projections.

Node.js quickstart

Install the SDK:

npm install openai
Enter fullscreen mode Exit fullscreen mode

Create a client with the Z.ai base URL:

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.GLM_API_KEY,
  baseURL: "https://api.z.ai/api/paas/v4",
});

const response = await client.chat.completions.create({
  model: process.env.GLM_MODEL || "glm-5.3",
  messages: [
    {
      role: "system",
      content:
        "You are a terminal automation agent. Return each step as a shell command with a one-line rationale.",
    },
    {
      role: "user",
      content:
        "A Node service on port 3000 stopped responding after a deploy. Give me a diagnosis sequence.",
    },
  ],
  temperature: 0.3,
  max_tokens: 2048,
});

console.log(response.choices[0].message.content);
console.log("usage:", response.usage);
Enter fullscreen mode Exit fullscreen mode

If your application already uses OpenAI, create a second OpenAI client with the Z.ai baseURL. This makes model comparisons a routing decision instead of an integration rewrite.

Stream responses

Set stream=True in Python:

stream = client.chat.completions.create(
    model=os.environ.get("GLM_MODEL", "glm-5.3"),
    messages=[
        {
            "role": "user",
            "content": "Explain the N+1 query problem with a concrete ORM example.",
        }
    ],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)
Enter fullscreen mode Exit fullscreen mode

For raw HTTP requests, send:

"stream": true
Enter fullscreen mode Exit fullscreen mode

Then parse server-sent event (SSE) data: lines using the OpenAI chunk format.

Two implementation details matter:

  1. Token usage is available at or after the final chunk, so finalize accounting only after the stream closes.
  2. With thinking enabled, hard prompts may have a longer time-to-first-token because the model reasons before emitting visible output.

Parameters that matter

Parameter Type What it does
max_tokens integer Caps output length. This is a primary cost control.
temperature number Use 0.20.4 for code and extraction; use 0.7+ for more open-ended writing.
thinking object {"type": "enabled"} enables reasoning mode for multi-step tasks.
stream boolean Returns server-sent events instead of a single response.
messages array Standard OpenAI-compatible system, user, and assistant messages.

Zhipu had not published GLM-5.3-specific API pricing at launch. Check the official pricing page instead of relying on reseller estimates.

At the time of writing, the page listed:

Model Input price per 1M tokens Output price per 1M tokens
GLM-5.2 $1.40 $4.40
GLM-5 $1.00 $3.20

For repeated instructions, keep stable system prompts consistent so eligible requests can benefit from cached-input discounts. The cost-control patterns in this DeepSeek API price increase postmortem apply here as well.

Test GLM-5.3 in Apidog before writing application code

Use Apidog to validate request shape, compare models, and save fixtures before putting prompts into your application.

1. Create the chat completions request

Create:

POST /chat/completions
Enter fullscreen mode Exit fullscreen mode

Use the OpenAI-compatible request body:

{
  "model": "{{GLM_MODEL}}",
  "messages": [
    {
      "role": "user",
      "content": "Explain this error message."
    }
  ],
  "temperature": 0.3,
  "max_tokens": 1024
}
Enter fullscreen mode Exit fullscreen mode

2. Create regional environments

Create two environments:

  • zai-international
  • bigmodel-mainland

Set these variables:

Variable zai-international bigmodel-mainland
BASE_URL https://api.z.ai/api/paas/v4 https://open.bigmodel.cn/api/paas/v4
GLM_API_KEY Your international key Your mainland China key
GLM_MODEL glm-5.3 glm-5.3

Set the request URL to:

{{BASE_URL}}/chat/completions
Enter fullscreen mode Exit fullscreen mode

Set the authorization header at the environment level:

Authorization: Bearer {{GLM_API_KEY}}
Enter fullscreen mode Exit fullscreen mode

This prevents keys from being copied into saved requests and lets you switch regions without editing the endpoint.

3. Test reasoning mode side by side

Duplicate a request.

In one request, add:

"thinking": {
  "type": "enabled"
}
Enter fullscreen mode Exit fullscreen mode

Compare the same prompt across both requests:

  • time to first token
  • final latency
  • response quality
  • token usage

Use the result to decide which workloads justify reasoning mode.

4. Save successful responses as examples

Save good outputs as examples or fixtures. Reuse them for request-shape and schema validation without calling the live API repeatedly.

Then build regression scenarios that assert:

  • HTTP status
  • finish_reason
  • response schema
  • expected response content patterns
  • token usage thresholds

For a broader workflow, see the API testing guide for QA engineers.

Error handling and rate limits

Expect OpenAI-style errors with an error object containing fields such as message, type, and code.

Common status codes:

Status Typical cause What to do
400 Invalid request body or unknown model Validate JSON and confirm the model ID.
401 Missing, invalid, or revoked key Check GLM_API_KEY and authorization headers.
429 Rate limit reached Retry with exponential backoff and jitter.
5xx Transient provider failure Retry with bounded backoff and log request IDs if available.

Implement retries for 429 and 5xx errors. For example, in Python:

import random
import time
from openai import APIStatusError

def create_completion_with_retry(**kwargs):
    for attempt in range(5):
        try:
            return client.chat.completions.create(**kwargs)
        except APIStatusError as error:
            retryable = error.status_code == 429 or error.status_code >= 500

            if not retryable or attempt == 4:
                raise

            delay = min(2 ** attempt, 16) + random.uniform(0, 0.5)
            time.sleep(delay)
Enter fullscreen mode Exit fullscreen mode

Avoid hardcoding rate-limit assumptions. Check Z.ai’s official docs for current concurrency and tier limits.

Keep the model ID in configuration so you can roll back to glm-5.2 or another documented family model without redeploying code. The debugging workflow used for Grok’s API transfers directly because both APIs use the OpenAI-style format.

FAQ

What is the GLM-5.3 API model ID?

The expected model ID is glm-5.3, following the glm-5.2 and glm-5.1 naming pattern. However, the launch-day GLM-5 documentation listed glm-5, so confirm the currently supported ID before pinning it in production.

Does GLM-5.3 work with the OpenAI SDK?

Yes. Use the official openai packages for Python or Node.js, set the base URL to:

https://api.z.ai/api/paas/v4
Enter fullscreen mode Exit fullscreen mode

For mainland China, use:

https://open.bigmodel.cn/api/paas/v4
Enter fullscreen mode Exit fullscreen mode

The request and response shapes follow the chat completions standard, including streaming.

How much does GLM-5.3 cost?

Zhipu had not published GLM-5.3-specific pricing at launch. Use the official pricing page for current numbers. GLM-5.2 was listed at $1.40 per 1M input tokens and $4.40 per 1M output tokens.

How does GLM-5.3 compare with Claude and GPT?

Zhipu’s evaluations describe GLM-5.3 coding and agent capability as “approaching Claude Fable 5.” It reported CyberGym at 84.5% and ExploitBench at 54.4%. These are vendor-reported results, so validate performance using your own workload and prompt suite. For a broader comparison, see Grok 4.6 vs GPT-5.6 vs Claude Fable 5.

Can I run GLM-5.3 locally?

Not yet. Zhipu says open weights should arrive around August 28, 2026, through its Hugging Face organization. The GLM-5 family’s 744B-parameter MoE architecture is server-class infrastructure, not a typical laptop deployment.

Where GLM-5.3 fits in your stack

GLM-5.3 is worth evaluating for agent loops, code review, terminal automation, and multi-step coding tasks. The OpenAI-compatible API means the evaluation is low-effort:

  1. Create an API key.
  2. Run the cURL smoke test.
  3. Put the endpoint, API key, and model ID behind environment variables.
  4. Test thinking enabled and disabled with your production-like prompts.
  5. Save outputs as regression fixtures.
  6. Port the approved request into Python or Node.js.

Download Apidog to create separate regional environments, compare model configurations, inspect token usage, and turn working prompts into reusable API tests.

Top comments (0)