Fast mode

更新时间:
复制 MD 格式

Fast mode delivers higher TPS (Tokens Per Second) for latency-sensitive scenarios. This feature is currently in the preview stage.

Usage

Fast mode provides the following key features:

  • High-speed output: TPS is increased to 1.5 to 2 times that of the standard API, reaching 80 to 100 TPS. This is suitable for AI coding assistants, multi-step Agent reasoning, real-time conversations, and other latency-sensitive scenarios.

  • Token-based billing: The billing logic is the same as the standard API, with charges based on input and output tokens. For specific pricing, see Model inference pricing.

  • Special rate limiting: When the TPM quota is exceeded, rate limiting is not immediately enforced. Instead, requests are queued.

  • Preview stage: This feature is in the preview stage. Capabilities and specifications are subject to change.

To enable Fast mode, set the model parameter to the model ID listed in Supported models. No additional parameters are required. The endpoint is in the format https://{workspace_id}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1, where workspace_id can be found on the Business Space Management page after you switch to the corresponding region.

Basic call example:

curl -X POST https://{workspace_id}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.2-fast-preview",
    "messages": [{"role": "user", "content": "Who are you"}],
    "stream": false
}'

Supported models

China (Beijing)

Model

Pricing (per million tokens)

Input

Output

Cached input

glm-5.2-fast-preview

CNY 16

CNY 56

CNY 4

Singapore

Model

Pricing (per million tokens)

Input

Output

Cached input

glm-5.2-fast-preview

CNY 20.98

CNY 65.95

CNY 4.20

Examples

The glm-5.2 model returns a reasoning_content field by default for reasoning. During streaming, reasoning content and response content are delivered through delta.reasoning_content and delta.content respectively. Streaming call example:

from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ.get("API_KEY"),
    base_url=os.environ.get("BASE_URL"),
)

completion = client.chat.completions.create(
    model="glm-5.2-fast-preview",
    messages=[{"role": "user", "content": "Who are you"}],
    stream=True,
)

for chunk in completion:
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta
    if hasattr(delta, "reasoning_content") and delta.reasoning_content:
        print(delta.reasoning_content, end="", flush=True)
    if hasattr(delta, "content") and delta.content:
        print(delta.content, end="", flush=True)

Response example:

{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "model": "glm-5.2-fast-preview",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "reasoning_content": "...",
      "content": "..."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 137,
    "total_tokens": 151,
    "prompt_tokens_details": { "cached_tokens": 0 },
    "completion_tokens_details": { "reasoning_tokens": 127 }
  }
}

Billing

For the billing rules and pricing of Fast mode, see Model inference pricing.

Error codes

For the error codes that may occur when you call Fast mode and the corresponding solutions, see Error codes.