APIMart
Back to all models

GLM-5.2 API

Z.aiModel ID glm-5.2Text modelReleased June 16, 2026

Use GLM-5.2 to map an unfamiliar codebase before you change it, plan a library migration in steps that each pass the tests, or check a diff against your team’s engineering rules.

Max input
1,000,000 tokens
Max output
128,000 tokens
Input → output
Text → Text
  • Streaming
  • Cached input pricing
  • OpenAI SDK compatible

GLM-5.2 API use cases

Each use case comes with an illustrative example: source material, a prompt and a hand-written sample answer, not actual model output. Copy the prompt, swap in your own material and try it on GLM-5.2.

Try GLM-5.2 with your own material

Taking over a codebase

Give GLM-5.2 the directory tree, the README and the main entry points, and have it map which module does what and where a change should go. Check the map against the code before you rely on it.

Example: Where should the new export feature go?

Material

Directory tree
api/routes/invoices.ts · services/invoices/query.ts · services/reports/pdf.ts · workers/email.ts · shared/format/money.ts
README
Routes stay thin and call services. Anything that formats money must use shared/format.

PromptUsing the directory tree and README, say which modules a CSV export of invoices would touch and where the new code should live.

Sample answer · written by hand to show the reasoning

Add a route in api/routes/invoices.ts that only parses the filters and calls a new services/reports/csv.ts, placed next to pdf.ts. The CSV service reads rows through services/invoices/query.ts and formats amounts with shared/format/money.ts, as the README requires. workers/email.ts is untouched unless exports should also be emailed.

About the GLM-5.2 API

  • Built for long-horizon tasks

    Z.ai released GLM-5.2 on June 16, 2026 as its flagship for long-horizon work: the first GLM model with a solid 1M-token context, and up to 128K output tokens.

  • Open weights under MIT

    A 744B-parameter mixture-of-experts model with 40B active, published on Hugging Face under the MIT license. IndexShare cuts per-token compute by 2.9x at 1M context.

  • Thinking you can switch off

    Thinking is on by default at max effort; set effort to high for fewer tokens, or turn thinking off for quick answers. GLM-5.3 no longer allows turning it off.

  • GLM-5.2 API key and access

    You don’t need a separate GLM-5.2 API key: one APIMart key works for every model. Check the GLM-5.2 API pricing table on this page, then call the GLM 5.2 API through an OpenAI Chat Completions-compatible endpoint with the model ID glm-5.2.

GLM-5.2 official benchmark results

Selected results Z.ai published at launch.

  • SWE-bench Pro

    62.1

    Real software engineering tasks. Up from 58.4 for GLM-5.1 and ahead of GPT-5.5 (58.6); Claude Opus 4.8 scores 69.2.

  • Terminal Bench 2.1 (Terminus-2)

    81.0

    Multi-step tasks in a terminal. Up from 63.5 for GLM-5.1; Claude Opus 4.8 scores 85 and GPT-5.5 84.

  • FrontierSWE (Dominance)

    74.4

    Frontier-level software engineering tasks. More than double GLM-5.1 (30.5) and ahead of GPT-5.5 (72.6); Claude Opus 4.8 scores 75.1.

  • DeepSWE

    46.2

    Agentic software engineering. Up from 18 for GLM-5.1; Claude Opus 4.8 scores 58 and GPT-5.5 70.

  • MCP-Atlas (public)

    76.8

    Tool use through MCP servers. Up from 71.8 for GLM-5.1 and ahead of GPT-5.5 (75.3); Claude Opus 4.8 scores 77.8.

  • AIME 2026

    99.2

    Competition math. Ahead of GPT-5.5 (98.3) and Claude Opus 4.8 (95.7), up from 95.3 for GLM-5.1.

How to call the GLM-5.2 API

To call GLM-5.2, you only need an APIMart API key and your existing OpenAI SDK, or send plain HTTP requests.

POST /v1/chat/completions
curl https://api.apimart.ai/v1/chat/completions \
  -H "Authorization: Bearer $APIMART_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "glm-5.2",
  "messages": [
    {
      "role": "user",
      "content": "Describe how to design a clear API in three sentences."
    }
  ],
  "stream": false
}'

GLM-5.2 access details

Model IDglm-5.2
Base URLhttps://api.apimart.ai/v1
Endpoint/chat/completions

Common parameters

model
Required
messages
Required
stream
Optional
max_tokens
Optional
temperature
Optional
All request parameters, response fields and error codes

GLM-5.2 API request parameters

GLM-5.2 uses the general chat endpoint, POST /v1/chat/completions, with a JSON body. model and messages are required; every other parameter is optional.

ParameterTypeRequiredDescription
modelstringYesModel ID. Use glm-5.2 for this model.
messagesarrayYesConversation messages. Each message has a role (system, user, or assistant) and content. Include earlier messages for multi-turn conversations.
streambooleanNoWhether to stream the output. true returns chunks over SSE, false returns the full response at once. Default: true.
temperaturenumberNoOutput randomness, 0–2. Default: 1.0. Lower values give more deterministic output.
top_pnumberNoNucleus sampling, 0–1. Default: 1.0. Adjust this or temperature, not both.
max_tokensintegerNoMaximum number of tokens to generate for the reply.
frequency_penaltynumberNoFrequency penalty, -2.0 to 2.0. Default: 0. Positive values reduce repeated wording.
presence_penaltynumberNoPresence penalty, -2.0 to 2.0. Default: 0. Positive values encourage new topics.
stopstring | arrayNoUp to 4 stop sequences. Generation stops when any of them appears.
nintegerNoNumber of replies to generate. Default: 1.

Response fields

The response contains the fields below. Token usage is returned in usage, which you can use to check costs.

FieldTypeDescription
idstringUnique identifier for the request.
modelstringThe model that handled the request.
choicesarrayList of replies. Each item contains message (role and content) and finish_reason.
usageobjectToken usage: prompt_tokens, completion_tokens, and total_tokens.

Error codes

Failed requests return an error object with code, message, and type.

StatusTypeMeaning
400invalid_request_errorInvalid request parameters.
401authentication_errorThe API key is invalid or missing.
402payment_requiredInsufficient account balance.
403permission_errorNo permission to access this resource.
429rate_limit_errorToo many requests. Retry later.
500server_errorInternal server error.
502bad_gatewayGateway error. The service is temporarily unavailable.

GLM-5.2 API pricing

The GLM-5.2 API is billed by token usage, and prices depend on your membership tier. Prices below are per million tokens; 1 US dollar = 10 credits.

ItemGoldCurrent pricePlatinumDiamondOfficial priceYou save
Input9.1424Credits~$0.91428.6853Credits~$0.86858.2282Credits~$0.822811.428Credits~$1.142820%
Cached input2.2856Credits~$0.22862.1713Credits~$0.21712.057Credits~$0.20572.857Credits~$0.285720%
Output31.9984Credits~$3.199830.3985Credits~$3.039828.7986Credits~$2.879939.998Credits~$3.999820%

Prices are for reference only. View full pricing

Why call GLM-5.2 API through APIMart

  • 20% below official pricing

    GLM-5.2 API pricing is billed by token usage. Gold to Diamond member prices are 20%–28% below Z.ai's official prices, and cached input costs just $0.2286 per 1M tokens.

    See membership prices
  • One API key for 500+ models

    GLM-5.2, the rest of its family and 500+ models from GPT, Claude, Gemini and more share one API key and one account balance. Switching models is just a change to the model parameter.

  • Change two lines of existing code

    If you already use the OpenAI SDK, point base_url at https://api.apimart.ai/v1 and swap in your APIMart API key. Requests and responses keep the same format.

  • Try it online before you code

    Try GLM-5.2 with your own material in the Playground, no code or setup needed, and integrate once you like the results.

    Open Playground

Which Z.ai model should you choose?

Base prices per 1M tokens (USD). Your GLM-5.2 API key works for every model in the table; just change the model parameter.

Differences between Z.ai models
ComparisonGLM-5.2 CurrentGLM-5.3-FlashGLM-5.3
Best forLong-horizon coding, 1M-token context, Thinking on or offAgentic coding, Image, video & file input, Open weightsAgentic coding, Long-horizon tasks, Open weights
Input typesTextText, Image, Video, FileText
Input price$0.9142$0.06$1.12
Output price$3.1998$0.2$3.52

GLM-5.2 FAQ

Should I use GLM-5.2 or GLM-5.3?

Compare GLM-5.3 first for the hardest coding work. Z.ai built it on the same base model as GLM-5.2 and improved it through post-training, reporting 66.9 vs. 46.2 on DeepSWE v1.1 and 28.3 vs. 4.6 on Terminal Bench 3.0, and it publishes a guide for migrating from GLM-5.2. Stay on GLM-5.2 if you need to turn thinking off, which GLM-5.3 no longer allows, or if your prompts are already tuned for it. On APIMart both use the same API key, so you only change the model parameter.

How do I turn off thinking on GLM-5.2?

Thinking is on by default. According to Z.ai’s docs, send thinking with type set to disabled to turn it off; with the OpenAI SDK, pass it in extra_body. Turning it off gives faster replies for simple extraction or formatting. GLM-5.3 always thinks, so this switch is one of the practical differences between the two.

Which reasoning_effort values work on GLM-5.2?

GLM-5.2 has two effort levels, high and max, and max is the default. According to Z.ai’s API docs, low and medium are treated as high, xhigh is treated as max, and none or minimal make the model skip thinking. Use high when you want fewer output tokens and max for the hardest tasks.

How should I keep reasoning across tool calls?

Return the thinking together with the tool results. Z.ai’s docs say GLM-5.2 thinks between tool calls by default and that the thinking blocks should be passed back with the tool results. On the standard API, earlier reasoning is cleared by default (clear_thinking is true); to keep it across turns, set clear_thinking to false and send back the complete reasoning_content unchanged and in its original order.

Is GLM-5.2 open source?

Yes. Z.ai published the weights on Hugging Face as zai-org/GLM-5.2, with an FP8 version as zai-org/GLM-5.2-FP8, under the MIT license with no regional limits, and lists vLLM and SGLang support. With 744B total parameters, self-hosting needs a large multi-GPU server; the GLM 5.2 API lets you use it per token without running that hardware.

Does GLM-5.2 support JSON output and function calling?

Yes. Z.ai’s docs list function calling and structured output. Set response_format to json_object to get a JSON reply, and pass functions with the standard tools parameter; tool_choice accepts only auto. The stop parameter takes a single stop word.

How can I try this model online?

Click Start chatting or Open Playground to visit the existing APIMart Playground. Select GLM-5.2 in the text category to start exploring.

Which model ID does the GLM-5.2 API use?

Set model to glm-5.2. Copy the exact ID from the page heading or the integration details panel.

Is it compatible with the OpenAI SDK?

You can keep the OpenAI SDK. Set base_url to https://api.apimart.ai/v1, provide your APIMart API key, and use the model ID on this page.

What is the context window of GLM-5.2?

On APIMart, GLM-5.2 accepts up to 1,000,000 input tokens per request. Your prompt, earlier messages, and file content all count toward it.

How many tokens can it output at once?

GLM-5.2 can output up to 128,000 tokens in a single reply. Use the max_tokens parameter to set a lower limit.

How much does the GLM-5.2 API cost?

The GLM-5.2 API on APIMart is billed by token, and prices depend on your membership tier. Gold: $0.9142 per million input tokens and $3.1998 per million output tokens. Diamond: $0.8228 per million input tokens and $2.8799 per million output tokens. Prices may change; the pricing page has the current rates.

Does it support streaming?

Yes. The general chat endpoint streams over SSE by default. Set stream to false to receive the complete response at once.

How do I get an API key?

Sign in to APIMart and create a key on the API Keys page, then send it in the Authorization: Bearer header. The same key also works for other models on the platform.