Current as of April 2026. Zhipu AI’s GLM family is the current price-to-performance leader for developers who need massive context windows without the OpenAI or Anthropic tax. When integrated with OpenCode, these models excel at processing large repositories and executing complex tool calls at a fraction of the cost of their Western counterparts.

The quick answer

ModelInput / OutputContextBest For
GLM-4.7 Flash$0.06 / $0.40203KThe Budget King for Large-Scale Context
GLM-4.6$0.39 / $1.90205KThe Long-Form Code Generator
GLM-4.7$0.39 / $1.75203KThe Budget King for Large-Scale Context
GLM-5$0.72 / $2.3080KLogic-Heavy Reasoning for Complex Logic

Start with GLM-4.7 Flash unless you have a specific reason to pick another. At $0.06 per million input tokens, it is the most cost-effective way to feed a 200K token codebase into a CLI. It provides the best balance of speed and tool-calling reliability for daily development tasks.

GLM-4.7 Flash — The Budget King for Large-Scale Context

This is the primary choice for OpenCode users who need to index large directories. With a 203K context window and a price point of $0.06/M input and $0.4/M output, it allows for frequent, deep-context queries that would be prohibitively expensive on other providers. It handles basic function calling well enough for simple file operations.

GLM-4.6 — The Long-Form Code Generator

GLM-4.6 is nearly identical to GLM-4.7 in pricing but offers a significantly higher output cap of 131K tokens. Pick this model specifically if you are using OpenCode to generate entire boilerplate projects or massive refactors where the standard 32K or 64K limits would cause the model to truncate mid-file.

GLM-4.7 — The Budget King for Large-Scale Context

This is the primary choice for OpenCode users who need to index large directories. With a 203K context window and a price point of $0.06/M input and $0.4/M output, it allows for frequent, deep-context queries that would be prohibitively expensive on other providers. It handles basic function calling well enough for simple file operations.

GLM-5 — Logic-Heavy Reasoning for Complex Logic

GLM-5 is the premium offering with the best reasoning capabilities in the family. Although its context window is smaller at 80K, it is more reliable for complex multi-step tool calls and architectural decisions. Use this when the Flash model fails to follow intricate coding logic or nested function calls.

Setup in OpenCode

To use GLM with OpenCode, define a new provider in ~/.config/opencode/opencode.jsonc using the @ai-sdk/openai-compatible adapter. Set the base URL to the Zhipu AI endpoint and store your API key in ~/.local/share/opencode/auth.json. Ensure your model IDs follow the ‘z-ai/’ prefix format for proper routing.

Running through haimaker.ai

All GLM models are also available through haimaker.ai. Wire haimaker as a single OpenAI-compatible provider and you get GLM alongside every other frontier model:

{
  "provider": {
    "haimaker": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://api.haimaker.ai/v1"
      }
    }
  }
}

Direct provider setup

OpenCode ships with a built-in preset for Zhipu AI. You do not need to configure a custom provider — just drop your API key into ~/.local/share/opencode/auth.json:

{
  "z-ai": {
    "type": "api",
    "key": "your-z-ai-api-key"
  }
}

Restart OpenCode and Zhipu AI models appear under /models. For providers not in the built-in directory (or to hit them through a gateway like haimaker), see the custom provider guide.

Bottom line

GLM-4.7 Flash is the smartest financial move for a CLI tool like OpenCode, while GLM-5 provides the necessary logic for high-stakes architectural refactoring.

USE GLM IN OPENCODE WITH HAIMAKER


See our OpenCode custom provider guide. See our Haimaker + OpenCode setup.