Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Setup guide - From GLM and OpenCode docs

Use GLM in OpenCode

OpenCode ships built-in Z.AI and Z.AI Coding Plan providers. Both Z.ai's docs and OpenCode's provider docs document selecting Z.AI Coding Plan, pasting the API key, and picking a GLM model with /models.

Last verified 4 steps3 official sources

Steps

  1. Step 1.

    Install OpenCode (either method).

    Terminal
    curl -fsSL https://opencode.ai/install | bash
    
    npm install -g opencode-ai
  2. Step 2.

    Get your API key from Personal Coding Plan > Plan Overview (Individual) or Team Coding Plan > My Plan (Team).

  3. Step 3.

    Add the credential. Z.ai documents the CLI login; OpenCode's docs document the /connect command inside the TUI. Select Z.AI Coding Plan if you subscribe to the GLM Coding Plan, otherwise Z.AI.

    Terminal
    opencode auth login
    
    # or, inside OpenCode
    /connect
  4. Step 4.

    Enter your Z.AI API key when prompted, launch OpenCode, and select a GLM model.

    Terminal
    opencode
    /models

Caveats

  • Model ids come from Z.ai's How to Switch Models page; OpenCode's provider docs still show GLM-4.7 as the example model in /models.
  • Base URL is handled by the built-in provider; the value shown is Z.ai's documented OpenAI Chat Completions Coding Plan endpoint, not a setting the user enters.
  • Pick Z.AI Coding Plan for subscription quota; Z.AI (standard) bills pay-as-you-go. Coding Plan and Standard keys are separate since 2026-10-16.

FAQ

How do I use GLM in OpenCode?

OpenCode ships built-in Z.AI and Z.AI Coding Plan providers. Both Z.ai's docs and OpenCode's provider docs document selecting Z.AI Coding Plan, pasting the API key, and picking a GLM model with /models.

Which GLM model ids work in OpenCode?

The official docs read for this guide list glm-5.3 and glm-5.3-flash. Requests go to https://api.z.ai/api/coding/paas/v4.

Is this an official GLM and OpenCode setup?

The steps draw on both GLM's and OpenCode's docs. It was last checked against 3 official pages on October 17, 2026.

Sources

Last verified against 3 official pages.

Newsletter

New models, set up the day they ship

One email per week. New model releases, the coding tools that support them and how to wire them up.