Skip to content
Sign Up Free
OpenCode

GLM in OpenCode: Model ID and model verification

Configure GLM in OpenCode with your BetterToken API Key, Base URL, and exact Model ID. Verify the selected model and troubleshoot authentication and setup errors.

Use this guide only to select and verify GLM in OpenCode. For general API Key, Base URL, and opencode.json setup, start with the OpenCode setup guide, then return here with the exact GLM Model ID from the Setup dialog.

GLM settings

FieldValue
API KeyBetterToken API Key
Base URLhttps://bettertoken.ai/v1
ModelYOUR_GLM_MODEL_ID

GLM prerequisites

Connect GLM with /connect

Start OpenCode and run:

/connect

Choose Other, enter bettertoken as the provider id, and paste your BetterToken API Key. Then select bettertoken/YOUR_GLM_MODEL_ID and restart OpenCode.

Manual GLM configuration

Open ~/.config/opencode/opencode.json or a project-level opencode.json:

{
"$schema": "https://opencode.ai/config.json",
"model": "bettertoken/YOUR_GLM_MODEL_ID",
"provider": {
"bettertoken": {
"npm": "@ai-sdk/openai-compatible",
"name": "BetterToken",
"options": {
"baseURL": "https://bettertoken.ai/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"YOUR_GLM_MODEL_ID": {
"name": "YOUR_GLM_MODEL_ID"
}
}
}
}
}

Replace YOUR_API_KEY and YOUR_GLM_MODEL_ID with values from the Setup dialog. Do not reuse a Model ID from an old article; use one currently listed in the model plaza.

Verify GLM

Select bettertoken/YOUR_GLM_MODEL_ID in OpenCode and send a short prompt. A response without an API error confirms the setup. Fully restart OpenCode after editing JSON.

Common GLM errors

ErrorWhat to check
401Check the BetterToken API Key saved through /connect or in apiKey.
404Keep baseURL as https://bettertoken.ai/v1, without /chat/completions.
Model not foundCopy the full GLM Model ID again from the Setup dialog and use it in both JSON locations.
Configuration is not appliedCheck the project-level opencode.json, which can override the global file.

Technical details

Base URL and Model ID

Copy the exact Model ID from the model plaza.