api.foo
api.foo / Docs / GLM API (Z.ai) pricing and API key

GLM API (October 2026): GLM-5.3 Pricing, Free Models, API Keys, GLM Coding Plan and Code Examples

Updated · Tested on: macOS · curl · Python openai 3.32.0, anthropic 1.15.0 (request formats and error messages)
On this page

Short answer: the GLM API is run by Z.ai (Zhipu AI) at https://api.z.ai/api/paas/v4. It's OpenAI-compatible, and there's also an Anthropic-compatible endpoint at https://api.z.ai/api/anthropic that Claude Code can use. GLM-5.3, the flagship, costs $1.40 input / $0.26 cached / $4.40 output per million tokens with a 1M-token context. GLM-5.3-Flash costs $0.15 / $0.50. A few older Flash models are free. If you mainly code with agents, the GLM Coding Plan starts at $18 a month.

One change to know about first: since October 16, 2026, standard API keys and Coding Plan keys are separate. The key type decides how a call is billed, whatever endpoint you send it to. Details below.

Prices and rules are from Z.ai's developer documentation at docs.z.ai and its Coding Plan page, checked on October 17, 2026. We tested the request formats and error messages ourselves with test keys.

GLM API pricing

Current models

Prices per million tokens, in USD:

Model Context Input Cached input Output
glm-5.3 1M $1.40 $0.26 $4.40
glm-5.2 1M $1.40 $0.26 $4.40
glm-5.3-flashx 1M $0.37 $0.075 $1.25
glm-5.3-flash 1M $0.15 $0.03 $0.50

GLM-5.3 and GLM-5.3-Flash both allow up to 128K output tokens. GLM-5.3 is text-only. GLM-5.3-Flash and FlashX also take images, video and files, and Z.ai says FlashX runs at about 200 tokens a second.

Older text models still on sale include GLM-5.1 ($1.40 / $4.40), GLM-5 ($1 / $3.20), and GLM-4.7 and GLM-4.6 ($0.60 / $2.20).

Free models

Z.ai lists these at $0 for input, cached input and output:

  • glm-4.7-flash (text)
  • glm-4.5-flash (text)
  • glm-4.6v-flash (vision)

They're older and smaller than GLM-5.3-Flash, but fine for prototypes, classification or simple chat.

Images, tools and caching

  • GLM-Image costs $0.015 per image.
  • The built-in web search tool costs $0.01 per use.
  • Caching is automatic. Repeated context is billed at the cached input price, and storage for cached content is free for a limited time. You can see cache hits in usage.prompt_tokens_details.cached_tokens. Z.ai says caching is in open beta and hasn't published exactly how hits are triggered or how long content is kept.
  • Your balance updates a day late. Z.ai's billing history shows the previous day's usage, so today's spending isn't visible right away.

GLM vs other models

List prices per million tokens, input / output:

Model Input Output
GLM-5.3 $1.40 $4.40
GLM-5.3-Flash $0.15 $0.50
MiniMax-M3 $0.30 $1.20
DeepSeek V4 Pro (off-peak half price) $1.32 $3.96
Kimi K3 $3 $15
Claude Sonnet 5.5 $2 $10
GPT-6.1 Sol $2 $10

GLM-5.3 always reasons (see below), so count its reasoning tokens as output when you compare. See also DeepSeek API pricing, Kimi API and MiniMax API.

GLM-5.3 always reasons

GLM-5.3 can't switch reasoning off. You choose how hard it thinks with reasoning_effort:

Value Meaning
low Light reasoning
high Enhanced reasoning
max Deep reasoning (the default)

If your app sends thinking: {"type": "disabled"}, the request fails on GLM-5.3. Z.ai's migration advice: change it to enabled and set reasoning_effort to low before switching the model name. With streaming, read both delta.reasoning_content and delta.content. Z.ai recommends temperature 1.0 and top_p 0.95, and tuning only one of them.

How to get a GLM API key

  1. Go to the Z.ai Open Platform at z.ai and sign up or log in.
  2. Open Billing and top up your balance. Z.ai's docs mention bank cards and PayPal, and its FAQ says credit card top-ups with 3D Secure verification aren't supported yet, so use a card that doesn't require it.
  3. Open API Keys and create a key under Standard API Key.
  4. Store it in an environment variable, for example export ZAI_API_KEY="your-key".

Z.ai's payment terms say payments are non-refundable except where the law requires otherwise or Z.ai explicitly says so, so start with a small top-up. You can check your rate limits in the console under Rate Limits.

Z.ai or BigModel?

Zhipu AI runs two separate platforms:

Z.ai (international) BigModel (mainland China)
Console z.ai bigmodel.cn
API base URL https://api.z.ai/api/paas/v4 https://open.bigmodel.cn/api/paas/v4
Currency USD CNY

Accounts and keys don't carry over between them. A key from one platform won't work on the other's base URL.

Standard keys vs Coding Plan keys

Since October 16, 2026, Z.ai manages these key types separately:

You want Key to use How it's billed
Pay-as-you-go or usage bundles Standard API Key (API Keys page) Your account balance
Individual Coding Plan Key under API Keys → Personal Coding Plan Your plan quota
Team Coding Plan Team Plan Key (Team Coding Plan → My Plan) Team plan and seat rules

For keys created on or after October 16, the key type decides the billing, not the endpoint. A standard key used in Claude Code still bills your balance, even if you also have a Coding Plan. To use your plan, create a Coding Plan key and put that in your tool.

Keys created before October 16 kept their values and were classified automatically. Accounts that have ever had a Coding Plan got "Compatible" keys, which keep the old behavior: they use plan quota on the Coding Plan endpoints and bill the balance on the standard endpoint. When a plan expires, a Compatible key doesn't fall back to pay-as-you-go on plan endpoints. Create a Standard key and swap it in.

GLM Coding Plan

The Coding Plan is a subscription for using GLM models inside coding agents: Claude Code, Codex, Cline, OpenCode, Kilo Code, Roo Code, Cursor and others Z.ai lists as supported.

Plan Monthly Yearly (per month) Credits per 5 hours Credits per week
Lite $18 $12.60 2,000 10,000
Pro $80 $56 12,000 60,000
Max $168 $117.60 28,000 140,000

Quarterly billing is 20% off and yearly is 30% off. All plans include GLM-5.3 and GLM-5.3-Flash. Requests for GLM-5.2 and 5.1 are routed to GLM-5.3, and GLM-4.7 to GLM-5.3-Flash.

How credits work. A call costs (input tokens × input multiplier + cached tokens × cached multiplier + output tokens × output multiplier) ÷ 10,000. GLM-5.3's multipliers are 6.9, 1.7 and 24. GLM-5.3-Flash's are 2.3, 0.56 and 8, so Flash gives you about three times the usage. The 5-hour window resets 5 hours after use, and the weekly window every 7 days from when you subscribed.

Off-peak calls cost half. Peak hours are Monday to Friday, 14:00 to 18:00 Singapore time (UTC+8). That's 2 to 6 a.m. US Eastern daylight time, so if you work US hours almost all your usage counts at half rate. Weekends are off-peak all day.

Rules to know before you subscribe:

  • The plan works only in Z.ai's supported tools. Using it elsewhere can get your benefits restricted.
  • No account sharing. The terms also forbid reselling, proxying or otherwise providing the plan to third parties, or using it to power model capabilities for others.
  • Violations can lead to rate limiting or account freezes. Accounts with more than three violations may be banned.
  • It renews automatically. Z.ai's usage policy asks you to cancel at least 3 days before the next billing date, and plans aren't refundable, even unused.

If you're building an app or a service for other people, use the pay-as-you-go API with a standard key.

Base URLs and formats

Format Base URL Used by
OpenAI Chat Completions (standard API) https://api.z.ai/api/paas/v4 OpenAI SDK, most apps
OpenAI Chat Completions (Coding Plan) https://api.z.ai/api/coding/paas/v4 Coding tools on the plan
Anthropic Messages https://api.z.ai/api/anthropic Claude Code, Anthropic SDK
OpenAI Responses https://api.z.ai/api/v1 Tools that need the Responses API

Z.ai notes that accounts that have ever subscribed to a Coding Plan, even an expired one, can currently reach the model API only through the Chat Completions format.

Code examples

curl

curl https://api.z.ai/api/paas/v4/chat/completions \
  -H "Authorization: Bearer $ZAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "glm-5.3", "messages": [{"role": "user", "content": "Hello"}], "reasoning_effort": "low"}'

Python with the OpenAI SDK

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["ZAI_API_KEY"],
    base_url="https://api.z.ai/api/paas/v4/",
)
resp = client.chat.completions.create(
    model="glm-5.3",
    messages=[{"role": "user", "content": "Explain recursion in one sentence."}],
    reasoning_effort="high",
)
print(resp.choices[0].message.content)

Z.ai also has its own SDK, pip install zai-sdk.

Claude Code

Z.ai's guide puts the settings in ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_zai_api_key",
    "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.3[1m]",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.3[1m]",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash[1m]",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
    "API_TIMEOUT_MS": "3000000"
  }
}

Use a Coding Plan key here if you want plan quota. A standard key works too, but it bills your balance. The [1m] suffix tells Claude Code the model has a 1M-token context. For how Claude Code picks models and what the other variables do, see Claude Code with a custom API.

Errors

Z.ai returns an HTTP status plus its own business code in the body, like {"error":{"code":"1001","message":"..."}}. These are the ones you're most likely to hit.

HTTP Code Message What to do
401 401 token expired or incorrect Wrong or deleted key. This is what we got with an invalid key.
401 1001 Authentication parameter not received in Header, unable to authenticate No Authorization header. Check your environment variable.
429 1113 Insufficient balance or no resource package. Please recharge. Out of balance. Note it's 429, not 402, so don't treat every 429 as a rate limit.
429 1302 Rate limit reached for requests Slow down and retry with backoff.
429 1305 The service may be temporarily overloaded, please try again later Retry later.
429 1308, 1310, 1316–1321 Usage limit reached… resets at… Coding Plan 5-hour or weekly limit. Wait, or buy extra usage.
429 1309 Your GLM Coding Plan package has expired… Renew, or switch to a standard key.
400 1211 Unknown Model, please check the model code. Check the model name, for example glm-5.3.
400 1261 Prompt too long Trim the input.

A Responses API quirk. With an invalid key, https://api.z.ai/api/v1/responses returned HTTP 200 with the body {"code":401,"msg":"token expired or incorrect","success":false}. The OpenAI Python SDK (3.32.0) then raised TypeError: 'NoneType' object is not iterable instead of an authentication error. If you see that TypeError against Z.ai, check your key first. The Chat Completions and Anthropic endpoints returned a proper 401, and both SDKs raised AuthenticationError.

When a stream fails partway through inference, Z.ai doesn't return these codes. The reason arrives in the stream itself, so log stream events too.

Using GLM through a multi-model gateway

If you call GLM alongside Claude, GPT or Gemini, a gateway gives you one key and one bill. api.foo, the service that publishes these docs, serves glm-5.3 at its OpenAI-compatible endpoint, https://api.foo/v1. We confirmed the path with a test key. Prices are on the api.foo pricing page. Going direct to Z.ai gets you its free models and the Coding Plan, which a gateway doesn't.

Sources

Z.ai, checked October 17, 2026: Pricing, Quick Start, GLM-5.3, GLM-5.3-Flash, Migrate to GLM-5.3, Context caching, Errors, API key management, Coding Plan overview, Usage policy, Claude Code guide, FAQ, Subscription terms, Coding Plan prices; BigModel quick start.

FAQ

How much does the GLM API cost?

As of October 17, 2026, GLM-5.3, Z.ai's flagship, costs $1.40 per million input tokens, $0.26 per million cached input tokens and $4.40 per million output tokens. GLM-5.3-Flash costs $0.15 input and $0.50 output, and GLM-5.3-FlashX costs $0.37 and $1.25. Storage for cached input is free for a limited time.

Is the GLM API free?

Some GLM models are. Z.ai lists GLM-4.7-Flash, GLM-4.5-Flash and the vision model GLM-4.6V-Flash as free. The current models, GLM-5.3 and GLM-5.3-Flash, are paid.

How do I get a GLM API key?

Sign up on the Z.ai Open Platform at z.ai, top up your balance on the Billing page, then create a Standard API Key on the API Keys page. Call it at https://api.z.ai/api/paas/v4 with the OpenAI SDK or at https://api.z.ai/api/anthropic in the Anthropic format.

What is the GLM Coding Plan and how much is it?

It's a subscription for using GLM models in coding tools such as Claude Code, Cline and OpenCode. Lite is $18 a month, Pro $80 and Max $168, with 20% off quarterly and 30% off yearly. Usage is counted in credits per 5 hours and per week, and calls outside peak hours (Monday to Friday, 14:00 to 18:00 Singapore time) cost half the credits.

Why is my balance being charged when I have a GLM Coding Plan?

You're probably using a standard API key. Since October 16, 2026, standard keys and Coding Plan keys are separate. Standard keys always bill your balance, even in coding tools and even if you have a subscription. Create a key under Personal Coding Plan to use your plan quota.

What's the difference between Z.ai and BigModel?

Z.ai (z.ai, api.z.ai) is Zhipu AI's international platform, billed in USD. BigModel (bigmodel.cn, open.bigmodel.cn) is its platform for mainland China. They have separate consoles and keys, so use the base URL of the platform where you created your key.

Found a mistake? Email [email protected].