Coding Agent
Connect OpenCode to SoCLaaS
Add SoCLaaS as an OpenAI-compatible provider so OpenCode can use your gateway models for code editing, explanations, and terminal tasks.
Recommended: download a ready-made config. Open Portal → Client Setup, download the OpenCode config, and save it as ~/.config/opencode/opencode.jsonc. Merge it first if you already have an OpenCode configuration. Then run opencode.
The generated file already lists the models available to your key and sets a default. The portal also provides a soclaas.env file for loading SOCLAAS_API_KEY.
The API key portal is available from the NUS network, while the API gateway itself is reachable from the Internet. OpenCode changes often, so confirm the config shape against your installed version.
What you need
| Setting | Value |
|---|---|
| Base URL | https://soclaas-api.comp.nus.edu.sg/v1 |
| API key | From the SoCLaaS portal, stored in SOCLAAS_API_KEY |
| Model | A chat-capable ID from GET /v1/models |
Manual setup
Use these steps if you prefer not to download the generated config.
-
Get an API key
Sign in to the SoCLaaS portal from the NUS network and create a personal key. The portal can also download a
soclaas.envfile that setsSOCLAAS_API_KEYfor you. -
Export the key
export SOCLAAS_API_KEY="YOUR_API_KEY" -
Find a model ID
curl https://soclaas-api.comp.nus.edu.sg/v1/models \ -H "Authorization: Bearer $SOCLAAS_API_KEY"Copy the
idof a chat-capable model. -
Install OpenCode
curl -fsSL https://opencode.ai/install | bash opencode --version -
Add the provider
Create or edit
opencode.jsonin your project, or the global file at~/.config/opencode/opencode.json. ReplaceYOUR_MODEL_IDwith the ID from step 3.{ "$schema": "https://opencode.ai/config.json", "provider": { "soclaas": { "npm": "@ai-sdk/openai-compatible", "name": "SoCLaaS", "options": { "baseURL": "https://soclaas-api.comp.nus.edu.sg/v1", "apiKey": "{env:SOCLAAS_API_KEY}" }, "models": { "YOUR_MODEL_ID": { "name": "YOUR_MODEL_ID" } } } } } -
Select the model and run
Start OpenCode, then use
/modelsto pick the SoCLaaS model.opencode
Troubleshooting
- Provider not listed: validate the JSON and confirm the file is in the project root or the global config path.
- 401 or 403: confirm
SOCLAAS_API_KEYis exported before launching OpenCode. - Model missing: the
modelskey must match the gateway's model ID exactly. - Timeout: check your network connection and the gateway status.