OpenCode
Guide to configuring OpenCode — a TUI coding assistant — to call a model via GreenNode MaaS through the
@ai-sdk/openai-compatibleprovider.
Prerequisites
Prepare your key, Base URL, and model following Getting Started with AI Coding
Node.js installed
Pick your configuration by service type
OpenCode uses the OpenAI standard → baseURL includes /v1 on both service types. Only the host and the key type differ:
Service type
baseURL
Key
Model
PAYG
https://maas-llm-aiplatform-hcm.api.vngcloud.vn/v1
API Key from the API Keys page
openai/gpt-oss-120b
Token Plan
https://tokenplan.api.greennode.ai/v1
subscription-key from Plan Detail → Subscription keys tab
Model code on the plan's Models tab
Step 1 — Install OpenCode
npm install -g opencode-aiOr via Homebrew (macOS):
Step 2 — Get your key
Log in to the AI Platform Console
Go to API Keys → Create API Key
Name the key (5–50 characters, lowercase letters + numbers + hyphens)
Copy the API key you just created
Go to API Key → Token Plan → My Token Plans and open the plan you bought
Subscription keys tab → copy
default-keyor a key you createdModels tab → copy the Model code of the model you want
No plan yet? See Buy Token Plan.
Step 3 — Create the opencode.json config file
Create opencode.json in your project root. Copy the tab matching your service type:
Field reference:
$schema
Enables autocomplete/validation in your editor
model
Default model — format <provider-key>/<model-id>
provider.MAAS-chat
Provider key — the part before / in model must match exactly
npm
Adapter package — @ai-sdk/openai-compatible works with any OpenAI-style endpoint
options.baseURL
The endpoint for your service type, ending in /v1
options.apiKey
Your MaaS key — use {env:MAAS_API_KEY} instead of hardcoding
models
The models exposed from this provider
Step 4 — Provide the key
Because the config uses {env:MAAS_API_KEY}, the key isn't stored in the file — it's read from the environment at runtime. Use the key belonging to the same service type as the baseURL you set in Step 3.
Option A — Export an environment variable (recommended)
To set it automatically every time you open a terminal, add it to ~/.zshrc or ~/.bashrc:
Or set it inline for a single run:
Option B — Use a gitignored .env file in the project
Create a .env file (add it to .gitignore):
Run OpenCode after loading .env:
Step 5 — Run OpenCode and pick a model
Change into your project directory and run:
OpenCode starts with the default model declared in
modelin Step 3.Switch models during a session with
/models, then choose MAAS chat → your model from the list.

Add more models
To expose more models from the same endpoint, add entries to models:
You can only add models included in the plan — check the plan's Models tab.
Then pick one via /models, or change the top-level model to the new MAAS-chat/<model-id>.
Troubleshooting
provider not found / model won't load
model value doesn't match the provider key
The model value must start with MAAS-chat/
401 Unauthorized
Key wrong, expired, or not yet ACTIVE
Re-export MAAS_API_KEY; check the key status
401 while the key is still valid
Key and baseURL belong to different service types
Re-check the table at the top: a key from the API Keys page → the maas-llm-… host; a key from the Subscription keys tab → the tokenplan… host
403 Forbidden (Token Plan)
Model isn't included in the plan
Only declare models listed on the plan's Models tab
402 Payment Required (Token Plan)
Plan expired or was deleted
Buy the plan again or enable Auto-renew
404 on request
Base URL wrong or missing /v1
OpenCode is OpenAI-standard — baseURL must end with /v1
Connection timeout
Endpoint unreachable from your network
Check VPN / connectivity to *.api.vngcloud.vn (PAYG) or tokenplan.api.greennode.ai (Token Plan)
Model errors while auth is fine
Wrong model ID
PAYG: use the ID the portal publishes. Token Plan: use the Model code from the Models tab
Result
OpenCode now routes every request through the GreenNode endpoint for your chosen service type. Usage is recorded in the AI Platform Console → Usage.
Use Codex with Minimax via MaaS
Connect Claude Code to MaaS
Learn about Token Plan packages
View usage and billing
Need help?
If you've followed the steps and it's still not working, feel free to contact GreenNode Customer Support:
Email: support@greennode.ai
Hotline: 19001549
Help center: helpdesk.greennode.ai
Thank you for using GreenNode's services.
Last updated

