Alibaba Cloud Model Studio のモデルを OpenCode で使用します。
クイックスタート
- 1
プロバイダーを接続する
opencodeを実行し、/connectを入力して、ご利用の課金プランに対応するプロバイダーを選択し、API キーを入力します:- Token Plan
- 従量課金
- Coding Plan
Alibaba Token Plan (China) を選択し、エディションに対応する Token Plan API キーを入力します:- Token Plan Personal Edition:API Key を作成または表示
- Token Plan Team Edition:シートを割り当てて API Key を取得
Alibaba (China) を選択し、Model Studio の API キー を入力します。Alibaba Coding Plan (China) を選択し、Coding Plan の API キー を入力します。 - 2
モデルを選択する
/modelsを入力し、使用するモデルを選択します。 - 3
確認する
次のコマンドを実行して確認します:Copyopencode run "Hello"
設定ファイルで構成する
上記のオプションに加えて、設定ファイルを使用して接続することもできます。- 1
設定ファイルを開くか作成する
- macOS / Linux:
~/.config/opencode/opencode.json - Windows:
C:\Users\<username>\.config\opencode\opencode.json
- macOS / Linux:
- 2
設定を記述する
YOUR_API_KEYを、ご利用のプランの API キーに置き換えます。- Token Plan パーソナルエディション
- Token Plan チームエディション
- 従量課金
- Coding Plan
Copy{ "$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 } }, "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 } } } } } }Copy{ "$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 } }, "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 に置き換えます。Copy{ "$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 } } } } } }Copy{ "$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を設定します。
エラーコード
設定中にエラーが発生した場合は、ご利用の課金プランの FAQ ドキュメントを参照してください:- Token Plan: Personal Edition FAQ · Team Edition FAQ
- Pay-as-you-go: エラーコード
- Coding Plan: Coding Plan FAQ
FAQ
従量課金で節約プランを使用するには?
従量課金で節約プランを使用するには?
従量課金の接続方法は変わりません。Model Studio の汎用 API Key と Base URL を使用します。節約プランを購入すると自動的に有効になり、対象の利用料金が自動的に控除されます。詳細は節約プランをご参照ください。
必要なモデルが一覧にない
必要なモデルが一覧にない
OpenCode を最新バージョンにアップグレードしてから、
/models を再度確認してください。それでもモデルが見つからない場合は、opencode.json でカスタムプロバイダーを定義し、モデルを追加します。 リクエストが 401 Unauthorized を返す
リクエストが 401 Unauthorized を返す
API キーが選択したプロバイダーと一致していないか、キーが別の課金プランに属しています。
/connect を再度実行し、ご利用のプランのプロバイダーを選択して、正しいキーを入力してください。