すべてのプロダクト
Search
ドキュメントセンター

Alibaba Cloud Model Studio:OpenCode

最終更新日:Nov 23, 2026

Alibaba Cloud Model Studio のモデルを OpenCode で使用します。

クイックスタート

  1. 1

    プロバイダーを接続する

    opencode を実行し、/connect を入力して、ご利用の課金プランに対応するプロバイダーを選択し、API キーを入力します:

    Token Plan

    Alibaba Token Plan (China) を選択し、エディションに対応する Token Plan API キーを入力します:

    従量課金

    Alibaba (China) を選択し、Model Studio の API キー を入力します。

    Coding Plan

    Alibaba Coding Plan (China) を選択し、Coding Plan の API キー を入力します。

  2. 2

    モデルを選択する

    /models を入力し、使用するモデルを選択します。

  3. 3

    確認する

    次のコマンドを実行して確認します:

    opencode run "Hello"
    

設定ファイルで構成する

上記のオプションに加えて、設定ファイルを使用して接続することもできます。

  1. 1

    設定ファイルを開くか作成する

    • macOS / Linux: ~/.config/opencode/opencode.json
    • Windows: C:\Users\<username>\.config\opencode\opencode.json
  2. 2

    設定を記述する

    YOUR_API_KEY を、ご利用のプランの API キーに置き換えます。

    Token Plan パーソナルエディション

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "bailian-token-plan": {
          "npm": "@ai-sdk/anthropic",
          "name": "Alibaba Cloud Model Studio",
          "options": {
            "baseURL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1",
            "apiKey": "YOUR_API_KEY"
          },
          "models": {
            "auto": {
              "name": "Auto",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 393216
              }
            },
            "qwen4-max-preview": {
              "name": "Qwen4.0 Max Preview",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            },
            "qwen4-max": {
              "name": "Qwen4 Max",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 262144
              }
            },
            "qwen3.8-max": {
              "name": "Qwen3.8 Max",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            },
            "qwen3.8-flash": {
              "name": "Qwen3.8 Flash",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            },
            "qwen3.7-max": {
              "name": "Qwen3.7 Max",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "qwen3.7-plus": {
              "name": "Qwen3.7 Plus",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "qwen3.6-flash": {
              "name": "Qwen3.6 Flash",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4.1-flash": {
              "name": "DeepSeek V4.1 Flash",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4.1-flash-1017": {
              "name": "DeepSeek V4.1 Flash 1017",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4-pro": {
              "name": "DeepSeek V4 Pro",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4-pro-0813": {
              "name": "DeepSeek V4 Pro 0813",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4-flash-0731": {
              "name": "DeepSeek V4 Flash 0731",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "glm-5.3": {
              "name": "GLM-5.3",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 202752,
                "output": 16384
              }
            },
            "glm-5.2": {
              "name": "GLM-5.2",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 202752,
                "output": 16384
              }
            }
          }
        }
      }
    }
    

    Token Plan チームエディション

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "bailian-token-plan": {
          "npm": "@ai-sdk/anthropic",
          "name": "Alibaba Cloud Model Studio",
          "options": {
            "baseURL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1",
            "apiKey": "YOUR_API_KEY"
          },
          "models": {
            "auto": {
              "name": "Auto",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 393216
              }
            },
            "qwen4-max-preview": {
              "name": "Qwen4.0 Max Preview",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            },
            "qwen4-max": {
              "name": "Qwen4 Max",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 262144
              }
            },
            "qwen3.8-max": {
              "name": "Qwen3.8 Max",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            },
            "qwen3.8-flash": {
              "name": "Qwen3.8 Flash",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            },
            "qwen3.7-max": {
              "name": "Qwen3.7 Max",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "qwen3.7-plus": {
              "name": "Qwen3.7 Plus",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "qwen3.6-plus": {
              "name": "Qwen3.6 Plus",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "qwen3.6-flash": {
              "name": "Qwen3.6 Flash",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4.1-flash": {
              "name": "DeepSeek V4.1 Flash",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4.1-flash-1017": {
              "name": "DeepSeek V4.1 Flash 1017",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4-pro": {
              "name": "DeepSeek V4 Pro",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4-pro-0813": {
              "name": "DeepSeek V4 Pro 0813",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4-flash-0731": {
              "name": "DeepSeek V4 Flash 0731",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "kimi-k2.7-code": {
              "name": "Kimi K2.7 Code",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 262144,
                "output": 98304
              }
            },
            "kimi-k2.6": {
              "name": "Kimi K2.6",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 262144,
                "output": 98304
              }
            },
            "kimi-k2.5": {
              "name": "Kimi K2.5",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 262144,
                "output": 98304
              }
            },
            "glm-5.3": {
              "name": "GLM-5.3",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 202752,
                "output": 16384
              }
            },
            "glm-5.2": {
              "name": "GLM-5.2",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 202752,
                "output": 16384
              }
            },
            "glm-5.1": {
              "name": "GLM-5.1",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 202752,
                "output": 16384
              }
            },
            "glm-5": {
              "name": "GLM-5",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 202752,
                "output": 16384
              }
            },
            "MiniMax-M2.5": {
              "name": "MiniMax M2.5",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 196608,
                "output": 32768
              }
            }
          }
        }
      }
    }
    

    従量課金

    {WorkspaceId} を実際の ワークスペース ID に置き換えます。

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "bailian-payg": {
          "npm": "@ai-sdk/anthropic",
          "name": "Alibaba Cloud Model Studio",
          "options": {
            "baseURL": "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1",
            "apiKey": "YOUR_API_KEY"
          },
          "models": {
            "qwen3.8-max": {
              "name": "Qwen3.8 Max",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            },
            "qwen3.7-plus": {
              "name": "Qwen3.7 Plus",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "qwen3.8-flash": {
              "name": "Qwen3.8 Flash",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 131072
              }
            },
            "deepseek-v4-pro-0813": {
              "name": "DeepSeek V4 Pro 0813",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "deepseek-v4.1-flash": {
              "name": "DeepSeek V4.1 Flash",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            }
          }
        }
      }
    }
    

    Coding Plan

    {
      "$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.7-plus": {
              "name": "Qwen3.7 Plus",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "qwen3.6-plus": {
              "name": "Qwen3.6 Plus",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            },
            "kimi-k2.5": {
              "name": "Kimi K2.5",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 262144,
                "output": 98304
              }
            },
            "glm-5": {
              "name": "GLM-5",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 202752,
                "output": 16384
              }
            },
            "MiniMax-M2.5": {
              "name": "MiniMax M2.5",
              "modalities": {
                "input": [
                  "text"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 196608,
                "output": 32768
              }
            },
            "qwen3.5-plus": {
              "name": "Qwen3.5 Plus",
              "modalities": {
                "input": [
                  "text",
                  "image"
                ],
                "output": [
                  "text"
                ]
              },
              "limit": {
                "context": 1000000,
                "output": 65536
              }
            }
          }
        }
      }
    }
    

    注記qwen4-max-preview を使用する場合、1 回のリクエストあたりの出力上限はデフォルトで 32000 です。より長い出力が必要な場合は、OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX を設定します。

    注記qwen4-max を使用する場合、1 回のリクエストあたりの出力上限はデフォルトで 32000 です。より長い出力が必要な場合は、OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX を設定します。qwen4-max のコンテキスト長は 1M Token です。非思考モードの最大出力は 131,072 Token、思考と最終回答の合計は最大 262,144 Token です。デフォルトは reasoning_effort=high、thinking_budget=131072 です。

エラーコード

設定中にエラーが発生した場合は、ご利用の課金プランの FAQ ドキュメントを参照してください:

FAQ

従量課金で節約プランを使用するには?

従量課金の接続方法は変わりません。Model Studio の汎用 API Key と Base URL を使用します。節約プランを購入すると自動的に有効になり、対象の利用料金が自動的に控除されます。詳細は節約プランをご参照ください。

必要なモデルが一覧にない

OpenCode を最新バージョンにアップグレードしてから、/models を再度確認してください。それでもモデルが見つからない場合は、opencode.json でカスタムプロバイダーを定義し、モデルを追加します。

リクエストが 401 Unauthorized を返す

API キーが選択したプロバイダーと一致していないか、キーが別の課金プランに属しています。/connect を再度実行し、ご利用のプランのプロバイダーを選択して、正しいキーを入力してください。