Skip to content

GLM-5.2 ​

Deprecated

GLM-5.2 is deprecated as of 7 October 2026 and will be removed on 7 November 2026. Migrate to GLM-5.3 Flash before the removal date.

Overview ​

GLM-5.2 is a model from Z.ai, designed for long-horizon tasks with a 262,144-token context length. It marks a substantial leap in long-horizon capability over its predecessor GLM-5.1, delivering reliable performance across extended coding-agent trajectories. The model identifier is zai-org/glm-5.2-fp8 and is released under an MIT open-source license with no regional limits.

Supported languages: Multilingual

Input: Text

Output: Text, code, tool calls

Note

  1. GLM-5.2 supports reasoning effort control via the reasoning_effort parameter.
  2. Set reasoning_effort="high" for standard tasks with balanced performance and latency.
  3. Set reasoning_effort="max" (or omit) for challenging problems requiring maximum computation.
  4. Thinking mode can be disabled for faster responses by setting chat_template_kwargs.enable_thinking to false.
  5. This page documents the features currently exposed on Swisscom Inference Endpoints.

Use Cases: Long-horizon coding tasks, agentic workflows, complex debugging, large-scale code construction, automated research, performance optimization, and sustained engineering work.

Model Card: GLM-5.2 FP8

Key Capabilities ​

  • 262K Token Context: Solid 262,144-token context that stably sustains long-horizon work
  • Effort Level Control: Balance model capability against execution speed (High/Max effort levels)
  • Advanced Coding: Strongest open-source model on coding benchmarks (Terminal-Bench 2.1: 81.0, SWE-bench Pro: 62.1)
  • Improved Architecture: IndexShare reduces per-token FLOPs; MTP layer increases acceptance length by 20%
  • MIT License: Pure open-source with no regional limits or technical access borders

Benchmarks ​

Long-Horizon Coding (as of June 2026):

  • FrontierSWE: 74.4 (second only to Opus 4.8 at 75.1)
  • PostTrainBench: 34.3 (second only to Opus 4.8 at 37.2)
  • SWE-Marathon: 13.0 (second only to Opus series)

Standard Coding Benchmarks:

  • Terminal-Bench 2.1: 81.0 (highest-ranked open-source model)
  • SWE-bench Pro: 62.1 (highest-ranked open-source model)

GLM-5.2 is the highest-ranked open-source model across all three long-horizon benchmarks, demonstrating practical long-horizon delivery capability.

Reasoning Effort Control ​

GLM-5.2 introduces reasoning effort control enabling users to balance model capability against task execution speed and computational cost via the reasoning_effort parameter:

  • reasoning_effort="high": Standard reasoning mode for most tasks, balanced performance and latency
  • reasoning_effort="max" (or omit): Allocate additional computation for challenging tasks requiring higher performance (default)

As shown in benchmarks, GLM-5.2 delivers substantially stronger agentic coding performance than GLM-5.1 at comparable token budgets, with capability positioned between Claude Opus 4.7 and Claude Opus 4.8 under similar token consumption.

Thinking Mode ​

GLM-5.2 supports thinking mode for complex reasoning tasks. When enabled, the model generates step-by-step reasoning before producing the final answer.

Default behavior: Thinking is enabled by default for complex tasks.

To disable thinking: Add chat_template_kwargs.enable_thinking: false as a top-level parameter in the request.

When to disable thinking:

  • Fast, lightweight responses for everyday tasks
  • Simple queries that don't require deep reasoning
  • Low-latency applications where response time is critical

When to keep thinking enabled:

  • Complex coding tasks requiring multi-step analysis
  • Long-horizon problem solving
  • Tasks requiring careful consideration of trade-offs

Architecture ​

IndexShare for DSA ​

Every 4 transformer layers share a lightweight indexer, reducing computation of indexer dot product and topk operation in 3/4 layers. This reduces per-token FLOPs significantly.

MTP with IndexShare and KVShare ​

Improved MTP layer for speculative decoding with IndexShare, KV Share, rejection sampling, and end-to-end TV loss, increasing acceptance length by up to 20%.

Best Practices ​

  • Use reasoning_effort="high" for standard coding and reasoning tasks
  • Use reasoning_effort="max" (or omit) for complex debugging, large-scale implementation, or challenging problems
  • For long-horizon tasks, allocate sufficient max_completion_tokens budget (8192 or higher recommended)
  • When working with long context scenarios, the model maintains quality across long, messy coding-agent trajectories
  • For real-time applications requiring lower latency, use reasoning_effort="high" or disable thinking mode
  • For maximum performance on critical tasks, use reasoning_effort="max" despite higher computational cost
  • Disable thinking mode (enable_thinking: false) for simple queries to reduce latency

Endpoints ​

1. Create Chat Completion ​

POST /v1/chat/completions

Description ​

Generates a chat completion for text-only or tool-calling requests with effort level control.

Request Body ​

json
{
  "model": "zai-org/glm-5.2-fp8",
  "messages": [
    {
      "role": "user",
      "content": "Refactor this codebase to improve modularity."
    }
  ],
  "temperature": 0.7,
  "reasoning_effort": "max",
  "max_completion_tokens": 8192,
  "stream": false
}
FieldTypeRequiredDescription
modelstringYesID of the model to use. Only zai-org/glm-5.2-fp8 is available.
messagesarrayYesList of messages in the conversation.
temperaturenumberNoSampling temperature. Use 0.7 for standard tasks.
reasoning_effortstringNoControls reasoning depth. Values: "high" (balanced) or "max" (default, maximum computation).
max_completion_tokensintegerNoMaximum number of tokens to generate. For long-horizon tasks, use 8192 or higher.
streambooleanNoIf true, the response is streamed in chunks. Default: false.

Response (When stream is false) ​

json
{
  "id": "chat-abcdefg1234567",
  "object": "chat.completion",
  "created": 1770000000,
  "model": "zai-org/glm-5.2-fp8",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here's the refactored code with improved modularity..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 150,
    "completion_tokens": 2500,
    "total_tokens": 2650
  }
}

2. List Models ​

GET /v1/models

Description ​

Lists all available models and their metadata.

Response ​

json
{
  "object": "list",
  "data": [
    {
      "id": "zai-org/glm-5.2-fp8",
      "object": "model",
      "created": 1770000000,
      "owned_by": "SwissAI"
    }
  ]
}

Example Code Snippets ​

Note:
The production URL for this API is available in the corresponding plan for this model in the Digital Marketplace. To retrieve the URL:

  1. Navigate to the Digital Marketplace.
  2. Go to the Documentation section.
  3. Select the plan associated with the GLM-5.2 model.
  4. Locate the production URL provided in the plan details.
  5. Set up the environment variable API_URL to the production URL retrieved.

How to retrieve the production URL

1. Standard coding task with curl ​

bash
curl -X POST $API_URL/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "model": "zai-org/glm-5.2-fp8",
  "messages": [
    {
      "role": "user",
      "content": "Review this code and suggest improvements for performance and readability."
    }
  ],
  "temperature": 0.7,
  "max_completion_tokens": 4096
}'

2. Long-horizon task with Python (Max effort) ​

python
import os
import openai

client = openai.OpenAI(
    api_key=os.getenv("YOUR_API_KEY"),
    base_url=os.getenv("API_URL") + "/v1",
)

response = client.chat.completions.create(
    model="zai-org/glm-5.2-fp8",
    messages=[
        {
            "role": "system",
            "content": "You are an expert software engineer. Break down complex tasks into manageable steps."
        },
        {
            "role": "user",
            "content": "Implement a complete CI/CD pipeline for a microservices architecture with automated testing, containerization, and deployment to Kubernetes."
        }
    ],
    temperature=0.7,
    reasoning_effort="max",
    max_completion_tokens=16384,
)

print(response.choices[0].message.content)

3. Code debugging with Python ​

python
import os
import openai

client = openai.OpenAI(
    api_key=os.getenv("YOUR_API_KEY"),
    base_url=os.getenv("API_URL") + "/v1",
)

response = client.chat.completions.create(
    model="zai-org/glm-5.2-fp8",
    messages=[
        {
            "role": "user",
            "content": """
Debug this Python application that's experiencing memory leaks:

[Code snippet here]

The application processes large datasets and the memory usage grows continuously.
Identify the root cause and provide a fix.
"""
        }
    ],
    temperature=0.7,
    max_completion_tokens=8192,
)

print(response.choices[0].message.content)

4. Multi-turn conversation with conversation history ​

python
import os
import openai

client = openai.OpenAI(
    api_key=os.getenv("YOUR_API_KEY"),
    base_url=os.getenv("API_URL") + "/v1",
)

messages = [
    {
        "role": "user",
        "content": "I need to build a REST API for a task management system. What should I consider?"
    },
    {
        "role": "assistant",
        "content": "For a task management REST API, consider: 1) Data model design, 2) Authentication and authorization, 3) Rate limiting, 4) Versioning strategy..."
    },
    {
        "role": "user",
        "content": "Can you provide a detailed schema for the task and user models?"
    }
]

response = client.chat.completions.create(
    model="zai-org/glm-5.2-fp8",
    messages=messages,
    temperature=0.7,
    max_completion_tokens=4096,
)

print(response.choices[0].message.content)

5. Non-thinking mode for fast responses ​

python
import os
import openai

client = openai.OpenAI(
    api_key=os.getenv("YOUR_API_KEY"),
    base_url=os.getenv("API_URL") + "/v1",
)

response = client.chat.completions.create(
    model="zai-org/glm-5.2-fp8",
    messages=[
        {
            "role": "user",
            "content": "Provide a one-sentence summary of retrieval-augmented generation."
        }
    ],
    temperature=0.7,
    max_completion_tokens=512,
    extra_body={
        "chat_template_kwargs": {
            "enable_thinking": False
        }
    },
)

print(response.choices[0].message.content)

6. High effort mode for balanced performance ​

python
import os
import openai

client = openai.OpenAI(
    api_key=os.getenv("YOUR_API_KEY"),
    base_url=os.getenv("API_URL") + "/v1",
)

response = client.chat.completions.create(
    model="zai-org/glm-5.2-fp8",
    messages=[
        {
            "role": "user",
            "content": "Review this code and suggest improvements."
        }
    ],
    temperature=0.7,
    reasoning_effort="high",
    max_completion_tokens=4096,
)

print(response.choices[0].message.content)

Replace YOUR_API_KEY with the actual API key. The authentication flow is described in Inference Endpoints Overview.

Applications & Integrations ​

OpenCode Integration ​

GLM-5.2 can be configured as the default model for OpenCode to enable agentic workflows and long-horizon coding tasks.

Setup Instructions ​

1. Create the configuration file

For global config (applies to all projects):

bash
mkdir -p ~/.config/opencode

Create ~/.config/opencode/opencode.json with:

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "swisscom": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Swisscom AI Platform",
      "options": {
        "baseURL": "https://api.swisscom.com/products/swiss-ai-platform/glm-5.2/v1",
        "apiKey": "{env:SWISSCOM_API_KEY}"
      },
      "models": {
        "zai-org/glm-5.2-fp8": {
          "name": "GLM-5.2",
          "limit": {
            "context": 262144,
            "output": 16384
          }
        }
      }
    }
  },
  "model": "swisscom/zai-org/glm-5.2-fp8"
}

TIP

Using {env:SWISSCOM_API_KEY} instead of hardcoding your API key is recommended. Set it via:

bash
export SWISSCOM_API_KEY=your_actual_api_key

For per-project config, save as opencode.json in your project root instead.

2. Install the required package

bash
npm install @ai-sdk/openai-compatible

3. Start OpenCode

bash
opencode

INFO

Configuration is loaded at startup. After modifying the config file, restart OpenCode for changes to take effect.

4. Verify the configuration

bash
opencode debug config