GLM 5 API: Model IDs, API Keys, Base URLs and Your First Request

GLM 5 API guide: every GLM 5.x model ID, where to get a key, the right base URL, a first curl and Python call, and what one request really costs.

Quick answer: the GLM 5 API is an OpenAI-compatible chat completions API that serves five GLM 5.x model IDs: glm-5, glm-5.2, glm-5.3, glm-5.3-flash and glm-5.3-flashx. Get a key from the official Z.ai Open Platform and call https://api.z.ai/api/paas/v4, or use a gateway such as glm5.app with https://glm5.app/api/v1. The model ID and the base URL have to match the product your key belongs to. That mismatch causes most first-call failures.

This guide was checked on November 5, 2026 against Z.ai's quick start, pricing table, GLM-5 and GLM-5.3 model pages and Coding Plan quick start, plus glm5.app's own API docs. We did not run a benchmark for it. Prices and endpoints change, so re-check the linked pages before you budget.

Who this is for

You searched "GLM 5 API" and found a model page, an OpenRouter listing, three hosting vendors and a YouTube video promising a free key. None of them tells you which of the five GLM 5.x IDs to send, which base URL goes with your key, or why a key that works in Claude Code returns 401 from a Python script.

This is the hub page for the whole family. Read it to pick a model, get a key, send one working request and estimate the bill. Then go to the model-specific guides: the GLM 5.3 API reference covers reasoning parameters in depth, and the GLM 5.2 API tutorial covers streaming, tools and JSON mode step by step.

The GLM 5 API model IDs at a glance

Z.ai's pricing table lists these GLM 5.x rows, in USD per 1M tokens:

Model IDOfficial inputOfficial cached inputOfficial outputWhat it is for
glm-5.3$1.40$0.26$4.40Current flagship: hard coding, long agent runs
glm-5.3-flash$0.15$0.03$0.50Cheap, fast, multimodal coding model
glm-5.3-flashx$0.37$0.075$1.25Faster serving tier of Flash
glm-5.2$1.40$0.26$4.40Previous flagship, same base model as 5.3
glm-5$1.00$0.20$3.20The February 2026 foundation model

A few facts from the official model pages matter before you write code:

  • GLM-5.3 is text-only, has a 1M-token context window and up to 128K output tokens. Reasoning is always on. reasoning_effort accepts low, high or max, and the default is max. Sending thinking.type: "disabled" makes the request fail.
  • GLM-5.3 uses the same base model as GLM-5.2. Z.ai says the gains came from post-training. If you have an integration running on glm-5.2, switching the ID is mostly a quality decision, not a price one.
  • GLM-5 lists a 200K context window and 128K maximum output. Its open weights (744B total, 40B active parameters) are on Hugging Face under zai-org, which is why so many hosts serve it.

For the speed and price trade-off inside the 5.3 line, see GLM 5.3 vs GLM 5.3 Flash.

Step 1: Get a GLM 5 API key (two routes)

Official route (Z.ai). Z.ai's quick start gives the steps: sign in to the Z.ai Open Platform, top up on the Billing page if needed, then create a Standard API Key on the API Keys page. That key belongs to the pay-per-token model API.

The trap: Z.ai now manages keys for the standard API, Individual Coding Plan and Team Coding Plan separately. Its Coding Plan quick start says newly created keys for these three products are not interchangeable. A Coding Plan key also goes with a different base URL (below). If you bought the $18-a-month Coding Plan and expect a general-purpose API key, read our GLM 5.3 Coding Plan breakdown first. The plan is limited to officially supported coding tools.

Gateway route (glm5.app). glm5.app is a third-party service, not Z.ai. Create a key at /settings/apikeys. It starts with sk-glm5- and is shown once. API access unlocks after your account's first successful purchase (any credit pack or plan). Free welcome credits only work in the web app. We say this up front so you don't sign up expecting a free key.

Step 2: Pick the right base URL

Your keyProtocolBase URL
Z.ai standard API keyOpenAI Chat Completionshttps://api.z.ai/api/paas/v4
Z.ai Coding Plan keyOpenAI Chat Completionshttps://api.z.ai/api/coding/paas/v4
Z.ai Coding Plan keyAnthropic Messageshttps://api.z.ai/api/anthropic
Z.ai Coding Plan keyOpenAI Responseshttps://api.z.ai/api/v1
glm5.app keyOpenAI Chat Completions and Responseshttps://glm5.app/api/v1

The standard URL comes from Z.ai's quick start and the GLM-5 model page. The three Coding Plan URLs come from the Coding Plan quick start. The GLM-5.3 model page lists the same three URLs. It also notes that anyone who has ever had a Coding Plan, even an expired one, can currently reach the GLM-5.3 model API only through the OpenAI Chat Completions protocol.

Step 3: Send your first GLM 5 API request

curl, official API:

curl -X POST "https://api.z.ai/api/paas/v4/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ZAI_API_KEY" \
  -d '{
    "model": "glm-5.3",
    "messages": [{"role": "user", "content": "Explain what a race condition is in two sentences."}],
    "thinking": {"type": "enabled"},
    "reasoning_effort": "low"
  }'

We set reasoning_effort to low on purpose. GLM-5.3 defaults to max, which is right for complex coding and wasteful for a hello-world check.

Python, OpenAI SDK, glm5.app:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["GLM5_API_KEY"],
    base_url="https://glm5.app/api/v1",
)

completion = client.chat.completions.create(
    model="glm-5.3-flash",
    messages=[{"role": "user", "content": "Write a Python function that reverses a string."}],
)

print(completion.choices[0].message.content)
print(completion.usage)

To use Z.ai directly with the same code, change base_url to https://api.z.ai/api/paas/v4 and use your Z.ai key. Print usage on every early call. Reasoning models can spend more output tokens than the visible answer suggests, and output is the expensive side of every row above.

Not sure which IDs your key can call? On glm5.app, GET https://glm5.app/api/v1/models returns the exact list. Only IDs in that list are accepted.

Step 4: Choose a model by job

JobStart withWhy
Prototyping, chat features, classification, summariesglm-5.3-flashCheapest GLM 5.x row, multimodal, fast enough for interactive use
Hard refactors, multi-step agents, long repositoriesglm-5.3Flagship. 1M context, 128K output, adjustable reasoning effort
Existing code pinned to 5.2glm-5.2Same price as 5.3 officially. Upgrade when you can re-test
Lowest official cost on a larger modelglm-5Lowest official input and output rates of the three larger rows
Latency-sensitive agent loopsglm-5.3-flashxFaster serving of Flash. Check your route's price first

Rule of thumb: start every new integration on Flash. Move a request to glm-5.3 only after a failing test case shows Flash can't do it. Most teams overspend by defaulting to the flagship for everything.

What one request actually costs: official vs glm5.app

Here is a worked example. Take one coding-agent turn with 20,000 input tokens and 2,000 output tokens, no cache hits.

glm5.app bills API usage in credits from the same balance as chat: 100 credits = $1.80 of API usage, rounded up per request, minimum one credit per completed request. Its public per-1M-token rates come from glm5.app's API pricing docs.

Model IDOfficial Z.ai costglm5.app rate (in / out per 1M)glm5.app charge
glm-5.3-flash$0.0040$0.075 / $0.251 credit
glm-5.3$0.0368$1.40 / $4.403 credits
glm-5.2$0.0368$1.40 / $4.403 credits
glm-5$0.0264$1.50 / $5.003 credits
glm-5.3-flashx$0.0099$1.85 / $6.253 credits

What the table shows:

  • Flash is half the official list rate per token on glm5.app ($0.075 vs $0.15 input, $0.25 vs $0.50 output). But the one-credit minimum means very short requests cost more than the token math. Flash pays off on larger prompts.
  • glm-5.3 and glm-5.2 use the official per-token rates, but glm5.app gives no discount for cached input. Rounding up to whole credits adds a little per request. If you resend the same long context many times, Z.ai's $0.26 cached-input rate makes the official API cheaper.
  • glm-5 and glm-5.3-flashx cost more on glm5.app than at Z.ai. If those two are your main models, go direct.
  • Pack price matters. A credit costs about $0.013 on the $200 Scale Pack and about $0.022 on the $12 Plus Pack. Bigger packs lower your real cost.

For the full official billing logic, including caching and Coding Plan credits, see the GLM 5.3 pricing breakdown.

When glm5.app is the better route

glm5.app is worth it when convenience matters more than the lowest per-token price. One sk-glm5- key and one credit balance cover every GLM 5.x ID, plus Kimi, DeepSeek and other models, behind one OpenAI-compatible base URL. You don't need separate Coding Plan keys or tool-only endpoint rules. Pay-as-you-go packs never expire, and they accept Alipay and WeChat Pay. The same balance also pays for chat in the browser. Compare credit packs and plans, then follow the glm5.app API quickstart.

Go direct to Z.ai if you need context caching at scale, the Anthropic-protocol endpoint, or long outputs on FlashX. glm5.app caps FlashX completions at 8,192 tokens. Also go direct for heavy glm-5 or FlashX volume, or if you want the cheapest possible bill on one model.

Common GLM 5 API errors and fixes

SymptomLikely causeFix
401 from Z.aiCoding Plan key on the standard URL, or the reverseMatch the key type to the base URL table above
GLM-5.3 request rejected right awaythinking.type: "disabled" from older codeSet enabled and use reasoning_effort: "low"
402 payment_required (glm5.app)Account hasn't made its first purchaseBuy any pack or plan. Welcome credits don't cover the API
402 insufficient_quota (glm5.app)Paid balance can't cover the request reservationTop up, or set a lower max_completion_tokens
404 model_not_found (glm5.app)ID typo or an unlisted IDCall GET /models and copy the ID exactly
429 rate_limit_exceeded (glm5.app)Default limit is 60 requests per minute per keyBack off and retry, reduce concurrency, or raise the key's RPM
Bill much higher than expectedReasoning at max on simple promptsLower reasoning_effort and read usage on each response

glm5.app's error reference lists every status code and which ones are safe to retry.

FAQ

What is the best API for GLM-5?

It depends on volume and which models you use. For a single model at high volume with repeated context, Z.ai's official API is usually cheapest because of cached-input pricing. If you want one key across GLM 5.3, 5.2, Flash and other model families, with no Coding Plan endpoint rules, a gateway like glm5.app is simpler. OpenRouter is a third option, and it routes glm-5 across several hosts.

Is there a free GLM 5 API?

Not as a standing offer. Z.ai's pricing page, checked November 5, 2026, lists a paid rate for every GLM 5.x model. "Free GLM 5 API" videos usually describe time-limited promotions, so check the date before you rely on one. glm5.app's free credits work in the web app only. Our guide to free GLM 5.3 options tracks what is actually available.

How do I get a GLM 5 API key?

On Z.ai, create a Standard API Key on the Open Platform's API Keys page after signing in. On glm5.app, make any first purchase, then create a key at /settings/apikeys. Either way, store the key in an environment variable. Never commit it to code.

What is GLM 5 API pricing?

Officially, per 1M tokens: GLM-5.3 and GLM-5.2 cost $1.40 input and $4.40 output. GLM-5.3-Flash costs $0.15 and $0.50. GLM-5.3-FlashX costs $0.37 and $1.25. GLM-5 costs $1.00 and $3.20. glm5.app's rates are in the cost table above.

Is a GLM 5.3 API key different from a GLM 5 API key?

No. A standard Z.ai key can call every model on the pricing page. The model ID in the request decides which model runs. What changes the key is the product: standard API vs Individual vs Team Coding Plan. For GLM 5.3 parameters, read the GLM 5.3 API guide.

Bottom line

The GLM 5 API comes down to three choices: a model ID, a key type and the base URL that matches it. Start on glm-5.3-flash, move up to glm-5.3 when a test case needs it, and print usage until you trust your cost estimates. If you'd rather have one key and one balance across every GLM 5.x model than manage Z.ai key types, pick a credit pack on glm5.app and send your first request from the API docs.

Sources

Start Using GLM 5 Today

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