For the complete documentation index, see llms.txt. This page is also available as Markdown.

OpenCode

Guide to configuring OpenCode β€” a TUI coding assistant β€” to call a model via GreenNode MaaS through the @ai-sdk/openai-compatible provider, billed via internal credit-tokens.


Prerequisites

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-ai

Or via Homebrew (macOS):

brew install opencode

Step 2 β€” Get an API key from AI Platform

  1. Log in to the AI Platform Console

  2. Go to API Keys β†’ Create API Key

  3. Name the key (5–50 characters, lowercase letters + numbers + hyphens)

  4. Copy the API key (vn-...) you just created


Step 3 β€” Create the opencode.json config file

Create an opencode.json file at your project root:

Field explanations:

Field
Purpose

$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


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:


Step 5 β€” Run OpenCode and select a model

  1. Navigate to your project directory and run:

    OpenCode starts with MAAS-chat/openai/gpt-oss-120b as the default model.

  2. Switch models within the session with the /models command, then choose MAAS chat β†’ openai/gpt-oss-120b from the list.

OpenCode running with the openai/gpt-oss-120b model via GreenNode MaaS

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

Symptom
Cause
Fix

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.

I want to next...
Go to

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:

Thank you for using GreenNode's services.

Last updated