← Back to list

OpenCode on Starsg

OpenCode is an open-source terminal / editor coding assistant that natively supports a baseURL and apiKey per provider. Point all three providers (Claude / GPT / Gemini) at Starsg and you get one key, one usage view and one tool to drive them all.

ImportantBefore you start, prepare an API Key created in the console. If you don't have one yet, follow the link to create it.

1. Install OpenCode

Install globally via npm. Requires Node.js 18+.

bash
npm i -g opencode-ai

Run opencode once after install so it can scaffold the default config directory. Hit Ctrl+C as soon as the welcome screen shows up.

bash
opencode

2. Edit opencode.json

Generate an API Key in the Starsg console, then replace all three sk-abc...xyz placeholders below with that key. Keep the model names exactly as each provider expects — only the baseURL changes.

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "options": {
        "apiKey": "sk-abc...xyz",
        "baseURL": "https://api.starsg.ai"
      }
    },
    "openai": {
      "options": {
        "apiKey": "sk-abc...xyz",
        "baseURL": "https://api.starsg.ai/v1"
      }
    },
    "google": {
      "options": {
        "apiKey": "sk-abc...xyz",
        "baseURL": "https://api.starsg.ai"
      }
    }
  }
}
Note:When generating the key, pick the right channel for each provider (Claude / OpenAI / Gemini) and leave the «available models» selection at default — otherwise the gateway will block one of the three.

3. Move it into OpenCode's config directory

macOS — open the config folder from your terminal:

bash
open "$HOME/.config/opencode"

Windows — open the config folder from cmd:

bash
start "" "%USERPROFILE%\.config\opencode"

Drop the edited opencode.json into this folder, overwriting the existing one. If the bundle you downloaded ships a plugins/ directory, copy that in too.

4. Verify

Launch opencode again and type /models inside the interactive prompt. Seeing models from anthropic, openai and google means you're set.

bash
opencode
# In the interactive UI, type:
/models