Skip to content

[FEATURE]: Add GLM-5.2 model support for Z.AI provider #32172

@phalla-doll

Description

@phalla-doll

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Z.AI just released GLM-5.2 — their latest and most capable reasoning model. It is available to all Z.AI Coding Plan subscribers (Max, Pro, Lite) and supports a 1M context window, reasoning with configurable effort levels, and tool calling.

Specs (from Z.AI docs):

Feature Value
Model ID glm-5.2
Reasoning Yes — effort levels high (default) and max
Context window 1,000,000 tokens (1M)
Max output tokens 131,072
API OpenAI-compatible
Coding Plan endpoint https://api.z.ai/api/coding/paas/v4
Tool calling Yes

Current state: GLM-5.2 is not listed on models.dev (the Z.AI provider page lists up to GLM-5.1, GLM-5-Turbo, GLM-5V-Turbo), and there are no existing PRs or issues mentioning GLM-5.2.

What needs to happen

  1. Add GLM-5.2 to models.dev zai provider TOML — this is the prerequisite for opencode to pick it up via its model catalog (fromModelsDevProvider() in provider.ts). I will file a separate issue/PR there.

  2. Reasoning effort mapping for Z.AI API: GLM-5.2 supports high and max effort levels (Z.AI docs map Claude Code's /effort levels to these). PR feat(bedrock): add GLM-5 reasoning support on AWS Bedrock #28264 adds GLM-5 reasoning via variant: "high" on AWS Bedrock, but we need to confirm the Z.AI OpenAI-compatible API provider also maps effort/variant correctly.

  3. 1M context window handling: Z.AI docs use a [1m] suffix convention (e.g., glm-5.2[1m]) to enable 1M context. Opencode's model definition uses contextWindow directly — we should either define one model with contextWindow: 1000000, or investigate whether two variants are needed.

  4. Coding Plan base URL: The Coding Plan uses https://api.z.ai/api/coding/paas/v4 which differs from the standard endpoint on models.dev (https://api.z.ai/api/paas/v4). Users on the Coding Plan need to configure the correct base URL.

  5. Tool-call parsing: GLM-5 has known tool-call JSON parsing issues ([bug] GLM 5 keeps screwing up the json parsing of read tool calling #13982, fix(opencode): recover malformed GLM/NVIDIA tool calls #25971). GLM-5.2 should be verified against these to avoid regressions.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions