Skip to content

OpenCode

OpenCode is a terminal AI coding tool that connects to Alibaba Cloud Model Studio via Pay-as-you-go, Coding Plan, or Token Plan (Team Edition).

Install OpenCode

  1. Install Node.js (v18.0 or later).

  2. Run the following command in the terminal to install OpenCode:

    HELPCODEESCAPE-bash
    npm install -g opencode-ai

    Run the following command to verify the installation. If a version number is displayed, the installation was successful.

    HELPCODEESCAPE-bash
    opencode -v

Configure Access Credentials

Open the following file with a text editor:

  • macOS / Linux: ~/.config/opencode/opencode.json

  • Windows: C:\Users<username&gt;\.config\opencode\opencode.json

Write the configuration for your chosen plan:

  • Token Plan (Team Edition): Seat-based subscription; token consumption deducts Credits.

  • Coding Plan: Fixed monthly subscription; metered by model API calls.

  • Pay-as-you-go: Post-paid based on actual usage.

Token Plan (Team Edition)

You must first purchase a Token Plan (Team Edition) subscription and ensure it is active. You can purchase a subscription on the Token Plan (Team Edition) page.

Replace YOUR_API_KEY with the Token Plan (Team Edition) dedicated API Key. For available models, refer to Token Plan (Team Edition) supported models.

HELPCODEESCAPE-json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "bailian-token-plan": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Alibaba Cloud Model Studio",
      "options": {
        "baseURL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "qwen3.6-plus": {
          "name": "Qwen3.6 Plus",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 8192
            }
          }
        },
        "qwen3.6-flash": {
          "name": "Qwen3.6 Flash",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 8192
            }
          }
        },
        "deepseek-v4-pro": {
          "name": "DeepSeek V4 Pro"
        },
        "deepseek-v4-flash": {
          "name": "DeepSeek V4 Flash"
        },
        "deepseek-v3.2": {
          "name": "DeepSeek V3.2"
        },
        "kimi-k2.6": {
          "name": "Kimi K2.6",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 8192
            }
          }
        },
        "kimi-k2.5": {
          "name": "Kimi K2.5",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 8192
            }
          }
        },
        "glm-5.1": {
          "name": "GLM-5.1",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 8192
            }
          }
        },
        "glm-5": {
          "name": "GLM-5",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 8192
            }
          }
        },
        "MiniMax-M2.5": {
          "name": "MiniMax M2.5"
        }
      }
    }
  }
}

Coding Plan

Replace YOUR_API_KEY with the Coding Plan dedicated API Key. For available models, refer to Coding Plan supported models.

HELPCODEESCAPE-json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "bailian-coding-plan": {
      "npm": "@ai-sdk/anthropic",
      "name": "Alibaba Cloud Model Studio",
      "options": {
        "baseURL": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "qwen3.6-plus": {
          "name": "Qwen3.6 Plus",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "qwen3.5-plus": {
          "name": "Qwen3.5 Plus",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "qwen3-max-2026-01-23": {
          "name": "Qwen3 Max 0123"
        },
        "qwen3-coder-next": {
          "name": "Qwen3 Coder Next"
        },
        "qwen3-coder-plus": {
          "name": "Qwen3 Coder Plus"
        },
        "MiniMax-M2.5": {
          "name": "MiniMax M2.5"
        },
        "glm-5": {
          "name": "GLM-5",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "glm-4.7": {
          "name": "GLM-4.7",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "kimi-k2.5": {
          "name": "Kimi K2.5",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        }
      }
    }
  }
}

Pay-as-you-go

OpenCode has a built-in Alibaba (China) provider. You can use the Alibaba Cloud Model Studio pay-as-you-go service by setting an environment variable, without creating a configuration file.

Replace YOUR_API_KEY with your Alibaba Cloud Model Studio API Key. For available models, refer to OpenAI compatible - Supported models.

Add the following to your shell configuration file (such as ~/.bashrc or ~/.zshrc):

HELPCODEESCAPE-bash
export DASHSCOPE_API_KEY="YOUR_API_KEY"

After saving, run source ~/.bashrc or source ~/.zshrc to apply the configuration.

Verify Configuration

After saving the configuration, restart OpenCode, type /models, search for Alibaba Cloud Model Studio (for pay-as-you-go, search for Alibaba (China)), and select the model you want to use to start a conversation.

FAQ

Error Codes

If you encounter errors during configuration, refer to the FAQ documentation for the corresponding billing plan:

  • Pay-as-you-go: Error Code Troubleshooting

  • Coding Plan: Coding Plan FAQ

  • Token Plan (Team Edition): Token Plan (Team Edition) FAQ

Mirror of Alibaba Cloud Model Studio docs for reference and RAG. Not affiliated with Alibaba Cloud.