OpenCode
Guide to configuring OpenCode β a TUI coding assistant β to call a model via GreenNode MaaS through the
@ai-sdk/openai-compatibleprovider, billed via internal credit-tokens.
Prerequisites
Prepare your API key, Base URL, and model following Getting Started with AI Coding
Node.js installed
The GLM 5.2 model via OpenCode uses the OpenAI standard β the Base URL includes
/v1:https://maas-llm-aiplatform-hcm.api.vngcloud.vn/v1.
Using a Token Plan (subscription package) key instead of a pay-as-you-go API key? Use https://tokenplan.api.greennode.ai/v1 as the Base URL instead. See Token Plan for details.
Step 1 β Install OpenCode
npm install -g opencode-aiOr via Homebrew (macOS):
brew install opencodeStep 2 β Get an API key from AI Platform
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 (
vn-...) you just created
A newly created API key starts in pending status. Wait until status = ACTIVE before using it.
Step 3 β Create the opencode.json config file
Create an opencode.json file at your project root:
Field explanations:
$schema
Enables autocomplete/validation in your editor
model
Default model β format <provider-key>/<model-id>
provider.MAAS-chat
Provider key β must exactly match the part before / in model
npm
Adapter package β @ai-sdk/openai-compatible works for any OpenAI-style endpoint
options.baseURL
MaaS endpoint, ending with /v1
options.apiKey
MaaS token β use {env:MAAS_API_KEY} instead of hardcoding
models
List of models exposed from this provider
Common mistake: setting "model" to a name that doesn't match a registered provider key. OpenCode splits on the first / to find the provider β if it doesn't match, the model won't load. Always use MAAS-chat/openai/gpt-oss-120b.
Step 4 β Provide the API key
Since the config uses {env:MAAS_API_KEY}, the key isn't in the file but is read from an environment variable at runtime. There are two ways:
Option A β Export an environment variable (recommended)
Export the key in your shell, then run OpenCode in the same session:
To do this 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 your project
Create a .env file (add it to .gitignore):
Run OpenCode by loading the .env file first:
Don't hardcode your API key directly in opencode.json if that file gets committed. If a key has already been committed, rotate it immediately in the MAAS Console since it must be treated as leaked.
Step 5 β Run OpenCode and select a model
Navigate to your project directory and run:
OpenCode starts with
MAAS-chat/openai/gpt-oss-120bas the default model.Switch models within the session with the
/modelscommand, then choose MAAS chat β openai/gpt-oss-120b from the list.

Adding other MaaS models
To expose more models from the same MaaS endpoint, add entries to models:
Then select 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
Use MAAS-chat/openai/gpt-oss-120b
401 Unauthorized
Wrong, expired, or not-yet-ACTIVE API key
Re-export MAAS_API_KEY; rotate the token in the MAAS Console
404 when sending a request
Wrong Base URL or missing /v1
Check baseURL ends with /v1
Connection timeout
Endpoint unreachable from the current network
Check VPN / connection to *.api.vngcloud.vn
Model errors but auth is correct
Wrong model ID
Use the exact ID published by MaaS (openai/gpt-oss-120b)
Result
Once done, OpenCode routes all requests through GreenNode MaaS. Usage is logged on the AI Platform Console β Usage.
Use Codex with Minimax via MaaS
Connect Claude Code to MaaS
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

