DeepSeek-V4.1-Flash1M context, web search, and tool calling fully supported
Try it now

GLM-5.2

glm-5.2
Open sourceGLM series

Overview

1M ContextReasoningCode generationAgentic tasks

GLM-5.2 is the flagship base model of the GLM-5 series, covering text generation, deep reasoning and code engineering. Aiming at "staying usable across long tasks", we redesigned the context-compression path and the goal-consistency mechanism so the model reliably retains key constraints across multi-day engineering collaboration, and keeps aligning with user intent through long-chain tasks without context drift. Combined with tiered thinking effort, function calling, MCP tools and structured output, it can drive project-scale software development and complex automation pipelines.

Million-token context

A 1M-token context window loads project-scale codebases and very long documents in a single pass.

Long-horizon agents

Optimized for multi-step, long-running agentic workflows, maintaining engineering context throughout a task.

Tiered thinking modes

Effort levels such as high / xhigh cover everything from fast responses to deep reasoning.

Open weights, self-hostable

Open model weights support private deployment and enterprise customization.

Features

Tool calling✓
Structured output✓
Context caching✓
Batch✓
Web search✓
Streaming✓
Reasoning✓
MCP✓
Prefix completion✕
Fine-tuning✕

Pricing

Input$1.4/M tokens
Input (cache hit)$0.26/M tokens
Output$4.4/M tokens

Rate Limits & Context

Context Window1M
Max Output128K
RPM (requests/min)200
TPM (tokens/min)3M

Built-in Tools

code_interpreter

Responses API

web_extractor

Responses API

web_search

Responses API

API Reference

POSThttps://api.tokenfab.com/v1/chat/completions

Request Example

curl https://api.tokenfab.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKENFAB_API_KEY" \
  -d '{
    "model": "glm-5.2",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Implement quicksort in Python and include a time complexity analysis."}
    ]
  }'

Response Example

{
  "id": "chatcmpl-9d2k7f1",
  "object": "chat.completion",
  "created": 1784950000,
  "model": "glm-5.2",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Quicksort uses divide and conquer: pick a pivot, partition the array into elements smaller and larger than the pivot, sort each part recursively, then combine. Best case O(n log n), worst case O(n²)."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 128,
    "total_tokens": 143
  }
}

Request Parameters

ParameterTypeRequiredDescription
modelstring✓Model ID, e.g. glm-5.2 or GLM-5.1
messagesarray✓List of chat messages, each with role and content
temperaturefloat—Sampling temperature, 0–2, default 0.7
top_pfloat—Nucleus sampling, 0–1, default 0.9
max_tokensint—Maximum output tokens
streambool—Whether to stream the response, default false
toolsarray—Tool definitions for function calling
tool_choicestring—Tool choice policy: auto / none / a named function