APIMart
Back to all models

GLM-5 API

Z.aiModel ID glm-5Text modelReleased February 12, 2026

Use GLM-5 to find why a cache serves the wrong price, decide how to split database load before you change the schema, or have an agent check vendor facts with web search and say what it could not confirm.

Max input
200,000 tokens
Max output
128,000 tokens
Input → output
Text → Text
  • Streaming
  • OpenAI SDK compatible

GLM-5 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.

Try GLM-5 with your own material

Fixing stubborn bugs

Give GLM-5 the failing code, the log lines around the failure and what you expected to happen, and ask for the cause before the fix. Reproduce the bug yourself with its explanation before you merge the change.

Example: Why does the cache show some users the wrong currency?

Material

Code
key = "price:" + str(product_id) if cached := cache.get(key): return cached price = pricing.get(product_id, currency=user.currency) cache.set(key, price, ttl=600)
Report
A user in Germany saw $49 instead of €45 a few minutes after a US user opened the same product.

PromptFind why some users see prices in the wrong currency, explain the cause and give the smallest fix.

Sample answer · written by hand to show the reasoning

The cache key has only the product ID, so the first price stored for a product is served to everyone for 10 minutes, whatever their currency. Add the currency to the key, for example price:<product_id>:<currency>. Clear the existing price:* entries when you deploy, or wait for the 600-second TTL to expire.

About the GLM-5 API

  • Built for agentic engineering

    Z.ai released GLM-5 on February 12, 2026 for complex system work and long-running agent tasks, such as backend architecture, hard algorithms and stubborn bugs.

  • Open weights under MIT

    A mixture-of-experts model with 744B total and 40B active parameters, pre-trained on 28.5T tokens and published on Hugging Face under the MIT license. It is the first GLM model with DeepSeek Sparse Attention.

  • Thinking you can switch off

    Thinking is on by default and can be turned off for quick answers. Function calling, structured output and streaming are supported, with a 200K context and up to 128K output tokens.

  • GLM-5 API key and access

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

GLM-5 official benchmark results

Selected results Z.ai published at launch.

  • SWE-bench Verified

    77.8

    Real GitHub issues fixed in Python repositories. Ahead of Gemini 3 Pro (76.2); Claude Opus 4.5 scores 80.9 and GPT-5.2 80.0.

  • SWE-bench Multilingual

    73.3

    The same kind of issues across many programming languages. Ahead of GPT-5.2 (72.0); Claude Opus 4.5 scores 77.5.

  • Terminal-Bench 2.0 (Terminus 2)

    56.2

    Multi-step tasks in a terminal. Ahead of Gemini 3 Pro (54.2); Claude Opus 4.5 scores 59.3.

  • BrowseComp

    62.0

    Finding hard-to-locate facts by browsing the web. Claude Opus 4.5 scores 37.0 and Gemini 3 Pro 37.8.

  • MCP-Atlas (public set)

    67.8

    Tool use through MCP servers. Ahead of Claude Opus 4.5 (65.2); GPT-5.2 scores 68.0.

  • τ²-Bench

    89.7

    Customer-service agents that follow policies while using tools. Claude Opus 4.5 scores 91.6 and Gemini 3 Pro 90.7.

How to call the GLM-5 API

To call GLM-5, 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",
  "messages": [
    {
      "role": "user",
      "content": "Describe how to design a clear API in three sentences."
    }
  ],
  "stream": false
}'

GLM-5 access details

Model IDglm-5
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 API request parameters

GLM-5 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 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 API pricing

The GLM-5 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
Input8Credits~$0.87.6Credits~$0.767.2Credits~$0.7210Credits~$120%
Output12.8Credits~$1.2812.16Credits~$1.21611.52Credits~$1.15216Credits~$1.620%

Prices are for reference only. View full pricing

Why call GLM-5 API through APIMart

  • 20% below official pricing

    GLM-5 API pricing is billed by token usage. Gold to Diamond member prices are 20%–28% below Z.ai's official prices.

    See membership prices
  • One API key for 500+ models

    GLM-5, 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 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 API key works for every model in the table; just change the model parameter.

Differences between Z.ai models
ComparisonGLM-5 CurrentGLM-5.1GLM-5.2GLM-5.3-FlashGLM-5.3
Best forAgentic engineering, Bug fixing, Thinking on or offLong-horizon agents, Agentic coding, Thinking on or offLong-horizon coding, 1M-token context, Thinking on or offAgentic coding, Image, video & file input, Open weightsAgentic coding, Long-horizon tasks, Open weights
Input typesTextTextTextText, Image, Video, FileText
Max input200,000 tokens200,000 tokens1,000,000 tokens1,000,000 tokens1,000,000 tokens
Input price$0.8$0.8$0.9142$0.06$1.12
Output price$1.28$1.44$3.1998$0.2$3.52

GLM-5 FAQ

Should I use GLM-5 or GLM-5.1?

GLM-5.1 is Z.ai’s follow-up for long-horizon tasks: Z.ai says it can work on one task for up to 8 hours, and its model card shows it ahead of GLM-5 on SWE-Bench Pro (58.4 vs. 55.1) and Terminal-Bench 2.0 (63.5 vs. 56.2). Z.ai lists GLM-5 at a lower price, and both have a 200K context, 128K max output and switchable thinking. For long agent runs try GLM-5.1; for shorter tasks GLM-5 may be enough. On APIMart you switch by changing only the model parameter.

How do I turn off thinking on GLM-5?

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.

Is GLM-5 open source?

Yes. Z.ai published the weights on Hugging Face as zai-org/GLM-5 under the MIT license. It is a 744B-parameter mixture-of-experts model with 40B active, so self-hosting needs a large multi-GPU server; the GLM 5 API lets you use it per token instead.

Does GLM-5 accept images?

No. Z.ai lists text as GLM-5’s only input and output. For screenshots, charts or scanned pages, GLM-5.3-Flash, the first natively multimodal model in Z.ai’s GLM-5 series, reads images and works with the same APIMart API key.

Does GLM-5 support JSON output and function calling?

Yes. Z.ai’s docs list function calling, structured output, streaming and context caching for GLM-5. Pass functions with the standard tools parameter, and set response_format to json_object when you need a JSON reply.

How can I try this model online?

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

Which model ID does the GLM-5 API use?

Set model to glm-5. 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?

On APIMart, GLM-5 accepts up to 200,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 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 API cost?

The GLM-5 API on APIMart is billed by token, and prices depend on your membership tier. Gold: $0.8 per million input tokens and $1.28 per million output tokens. Diamond: $0.72 per million input tokens and $1.152 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.