GLM 5.2
glm-5.2Open flagship GLM for long-horizon coding agents and million-token context work. It supports tool calling and cached-input billing. Call it through the chat completions endpoint with a messages array. Use it for large-scale refactoring, autonomous agent loops, and long-document question answering.
Auto route pricing
Route source: Tencent
- Input / Output
- Input: $0.789Output: $2.761
- Cache read / write
- Cache read: $0.276Cache write: Price not supplied
- Context / Max output
- 1000K / —
- Live routes
- 5
Rates / 1M tokens
Image output: Price not supplied
These are separate usage rates, not a total request price.
On this page
Overview
Open flagship GLM for long-horizon coding agents and million-token context work. It supports tool calling and cached-input billing. Call it through the chat completions endpoint with a messages array. Use it for large-scale refactoring, autonomous agent loops, and long-document question answering.
Playground
Other parameters (14)
Result preview
Tencent · 3177ms
Response example. Run to see the actual response.
{
"id": "chatcmpl-0758b9ab-bac7-99f3-a76c-a458c9979723",
"model": "glm-4.7",
"usage": {
"total_tokens": 230,
"prompt_tokens": 6,
"completion_tokens": 224,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 187
}
},
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm GLM, trained by Z.ai. How can I assist you today? Whether you have questions or just want to chat, I'm happy to help.",
"reasoning_content": "Let me consider how to respond to this greeting effectively.\n\nThe user has started with a simple \"hello\" - this is likely the beginning of a conversation. I should respond in a way that's both welcoming and open-ended.\n\nFirst, I should acknowledge their greeting warmly. Then I should introduce myself briefly to establish context. Since this is an initial interaction, I should also express my willingness to help while inviting them to share what's on their mind.\n\nI need to make sure my response is friendly and professional, while also being concise enough not to overwhelm. The goal is to create an inviting atmosphere for further conversation.\n\nLet me craft a response that's welcoming, informative, and encourages further dialogue. I should include:\n- A warm greeting back\n- A brief introduction of who I am\n- An expression of readiness to help\n- An invitation for them to continue the conversation\n\nThis should create a good foundation for a productive interaction."
},
"logprobs": null,
"finish_reason": "stop"
}
],
"created": 1784220767,
"openmodels_cost": 418,
"system_fingerprint": null
}Agent handoff preview
Providers
| Provider | Pricing | Latency | Uptime | Supply | Route |
|---|---|---|---|---|---|
Live | Input $0.118 / 1M tokens Output $0.413 Cache read $0.030 Cache write — | — | — | Community | |
Live | Input $0.281 / 1M tokens Output $0.900 Cache read — Cache write — | 2160ms | — | Community | |
Live | Input $0.789 / 1M tokens Output $2.761 Cache read $0.276 Cache write — | 3177ms | — | Verified | |
Live | Input $0.993 / 1M tokens Output $3.476 Cache read $0.276 Cache write — | 2406ms | — | Verified | |
Live | Input $0.993 / 1M tokens Output $3.476 Cache read $0.276 Cache write — | 0ms | — | Verified |
- Input
- $0.789
- Output
- $2.761
- Cache read
- $0.276
Source: the selected provider route in OpenAny's public model catalog. A price update timestamp is not supplied.
API
- Base URL
https://api.openany.si/v1- POST
/v1/chat/completions- Authentication
Authorization: Bearer $OPENANY_API_KEY
Request parameters
| Parameter | Type / range | Default value | Required | Description |
|---|---|---|---|---|
messages | array | — | Yes | messages |
model | string | — | Yes | model |
do_sample | boolean | true | No | do_sample |
max_tokens | integer · 1 ~ 131072 | — | No | max_tokens |
reasoning_effort | string · max | xhigh | high | medium | low | minimal | none | max | No | reasoning_effort |
request_id | string | — | No | request_id |
response_format | object | — | No | response_format |
route | object | — | No | route |
route_mode | string | — | No | route_mode |
stop | array | — | No | stop |
stream | boolean | false | No | stream |
temperature | number · 0 ~ 1 | 1 | No | temperature |
thinking | object | — | No | thinking |
tool_choice | string | — | No | tool_choice |
tool_stream | boolean | false | No | tool_stream |
tools | array | — | No | tools |
top_p | number · 0.01 ~ 1 | 0.95 | No | top_p |
user_id | string | — | No | user_id |
Request example
curl 'https://api.openany.si/v1/chat/completions' \
-H "Authorization: Bearer $OPENANY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"content": "Hello!",
"role": "user"
}
],
"model": "glm-5.2",
"route_mode": "balanced",
"do_sample": true,
"reasoning_effort": "max",
"stream": false,
"temperature": 1,
"tool_stream": false,
"top_p": 0.95
}'Response example
Configured response example · not a live result
{
"id": "chatcmpl-0758b9ab-bac7-99f3-a76c-a458c9979723",
"model": "glm-4.7",
"usage": {
"total_tokens": 230,
"prompt_tokens": 6,
"completion_tokens": 224,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 187
}
},
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm GLM, trained by Z.ai. How can I assist you today? Whether you have questions or just want to chat, I'm happy to help.",
"reasoning_content": "Let me consider how to respond to this greeting effectively.\n\nThe user has started with a simple \"hello\" - this is likely the beginning of a conversation. I should respond in a way that's both welcoming and open-ended.\n\nFirst, I should acknowledge their greeting warmly. Then I should introduce myself briefly to establish context. Since this is an initial interaction, I should also express my willingness to help while inviting them to share what's on their mind.\n\nI need to make sure my response is friendly and professional, while also being concise enough not to overwhelm. The goal is to create an inviting atmosphere for further conversation.\n\nLet me craft a response that's welcoming, informative, and encourages further dialogue. I should include:\n- A warm greeting back\n- A brief introduction of who I am\n- An expression of readiness to help\n- An invitation for them to continue the conversation\n\nThis should create a good foundation for a productive interaction."
},
"logprobs": null,
"finish_reason": "stop"
}
],
"created": 1784220767,
"openmodels_cost": 418,
"system_fingerprint": null
}Error handling
400Check the model ID and request fields.429Retry with exponential backoff.5xxRetry only temporary provider failures.JSON Schema
{
"type": "object",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"messages",
"model"
],
"properties": {
"stop": {
"type": "array",
"items": {
"type": "string"
},
"maxItems": 1
},
"model": {
"type": "string"
},
"route": {
"type": "object"
},
"tools": {
"type": "array",
"items": {
"type": "object",
"required": [
"type",
"function"
],
"properties": {
"type": {
"enum": [
"function"
],
"type": "string",
"default": "function"
},
"function": {
"type": "object",
"required": [
"name",
"description",
"parameters"
],
"properties": {
"name": {
"type": "string",
"pattern": "^[a-zA-Z0-9_-]+$",
"maxLength": 64,
"minLength": 1
},
"parameters": {
"type": "object",
"additionalProperties": true
}
}
}
},
"additionalProperties": false
},
"maxItems": 128
},
"top_p": {
"type": "number",
"format": "float",
"default": 0.95,
"maximum": 1,
"minimum": 0.01
},
"stream": {
"type": "boolean",
"default": false
},
"user_id": {
"type": "string",
"maxLength": 128,
"minLength": 6
},
"messages": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"required": [
"role",
"content"
],
"properties": {
"role": {
"enum": [
"user"
],
"type": "string",
"default": "user"
},
"content": {
"oneOf": [
{
"type": "string"
}
]
}
}
},
{
"type": "object",
"required": [
"role",
"content"
],
"properties": {
"role": {
"enum": [
"system"
],
"type": "string",
"default": "system"
},
"content": {
"oneOf": [
{
"type": "string"
}
]
}
}
},
{
"type": "object",
"required": [
"role"
],
"properties": {
"role": {
"enum": [
"assistant"
],
"type": "string",
"default": "assistant"
},
"content": {
"oneOf": [
{
"type": "string"
}
]
},
"tool_calls": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"type"
],
"properties": {
"id": {
"type": "string"
},
"type": {
"enum": [
"function",
"web_search",
"retrieval"
],
"type": "string"
},
"function": {
"type": "object",
"required": [
"name",
"arguments"
],
"properties": {
"name": {
"type": "string"
},
"arguments": {
"type": "string"
}
}
}
}
}
}
}
},
{
"type": "object",
"required": [
"role",
"content",
"tool_call_id"
],
"properties": {
"role": {
"enum": [
"tool"
],
"type": "string",
"default": "tool"
},
"content": {
"oneOf": [
{
"type": "string"
}
]
},
"tool_call_id": {
"type": "string"
}
}
}
]
},
"minItems": 1
},
"thinking": {
"type": "object",
"properties": {
"type": {
"enum": [
"enabled",
"disabled"
],
"type": "string",
"default": "enabled"
},
"clear_thinking": {
"type": "boolean",
"default": true
}
}
},
"do_sample": {
"type": "boolean",
"default": true
},
"max_tokens": {
"type": "integer",
"maximum": 131072,
"minimum": 1
},
"request_id": {
"type": "string",
"maxLength": 64,
"minLength": 6
},
"route_mode": {
"type": "string"
},
"temperature": {
"type": "number",
"format": "float",
"default": 1,
"maximum": 1,
"minimum": 0
},
"tool_choice": {
"oneOf": [
{
"enum": [
"auto"
],
"type": "string"
}
]
},
"tool_stream": {
"type": "boolean",
"default": false
},
"response_format": {
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"enum": [
"text",
"json_object"
],
"type": "string",
"default": "text"
}
}
},
"reasoning_effort": {
"enum": [
"max",
"xhigh",
"high",
"medium",
"low",
"minimal",
"none"
],
"type": "string",
"default": "max"
}
}
}Examples
Request example
POST /v1/chat/completionscurl 'https://api.openany.si/v1/chat/completions' \
-H "Authorization: Bearer $OPENANY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"content": "Hello!",
"role": "user"
}
],
"model": "glm-5.2",
"route_mode": "balanced",
"do_sample": true,
"reasoning_effort": "max",
"stream": false,
"temperature": 1,
"tool_stream": false,
"top_p": 0.95
}'