SoCLaaS

Home / Setup Guides / OpenCode

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

SettingValue
Base URLhttps://soclaas-api.comp.nus.edu.sg/v1
API keyFrom the SoCLaaS portal, stored in SOCLAAS_API_KEY
ModelA chat-capable ID from GET /v1/models

Manual setup

Use these steps if you prefer not to download the generated config.

  1. 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.env file that sets SOCLAAS_API_KEY for you.

  2. Export the key

    export SOCLAAS_API_KEY="YOUR_API_KEY"
  3. Find a model ID

    curl https://soclaas-api.comp.nus.edu.sg/v1/models \
      -H "Authorization: Bearer $SOCLAAS_API_KEY"

    Copy the id of a chat-capable model.

  4. Install OpenCode

    curl -fsSL https://opencode.ai/install | bash
    opencode --version
  5. Add the provider

    Create or edit opencode.json in your project, or the global file at ~/.config/opencode/opencode.json. Replace YOUR_MODEL_ID with 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"
            }
          }
        }
      }
    }
  6. Select the model and run

    Start OpenCode, then use /models to pick the SoCLaaS model.

    opencode

Troubleshooting