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
| Field | Value |
|---|---|
| API Key | BetterToken API Key |
| Base URL | https://bettertoken.ai/v1 |
| Model | YOUR_GLM_MODEL_ID |
GLM prerequisites
- Install OpenCode.
- Create a BetterToken API Key.
- Copy the exact Model ID from the model plaza.
Connect GLM with /connect
Start OpenCode and run:
/connectChoose 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
| Error | What to check |
|---|---|
401 | Check the BetterToken API Key saved through /connect or in apiKey. |
404 | Keep baseURL as https://bettertoken.ai/v1, without /chat/completions. |
| Model not found | Copy the full GLM Model ID again from the Setup dialog and use it in both JSON locations. |
| Configuration is not applied | Check the project-level opencode.json, which can override the global file. |
Related guides
Technical details
Base URL and Model ID
Copy the exact Model ID from the model plaza.

