GreenTokens

Search

Search models, guides, docs and the FAQ.

Clients

OpenCode

Add GreenTokens as an OpenAI-compatible provider in OpenCode.

Quick setup

Run the setup script in a terminal and choose OpenCode from its list. It finds OpenCode's settings, checks your API key, and makes the changes described below for you, backing up each file first. It can set up your other agents in the same run.

curl -fsSL https://www.greentokens.io/setup.sh | bash

The script saves your key as the GREENTOKENS_API_KEY environment variable, which OpenCode reads. Open a new terminal window afterwards so it picks it up.

To undo, run the same command again and choose Remove.

Add GreenTokens as a provider

OpenCode connects to any OpenAI-compatible API through a custom provider. Add GreenTokens to opencode.json in your project, or to ~/.config/opencode/opencode.json to use it everywhere:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "greentokens": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "GreenTokens",
      "options": {
        "baseURL": "https://api.greentokens.io/v1",
        "apiKey": "{env:GREENTOKENS_API_KEY}"
      },
      "models": {
        "claude-sonnet-5": { "name": "Claude Sonnet 5" },
        "claude-opus-5-5": { "name": "Claude Opus 5.5" },
        "gpt-6-sol": { "name": "GPT-6 Sol" },
        "glm-5.3": { "name": "GLM-5.3" }
      }
    }
  },
  "model": "greentokens/claude-sonnet-5"
}
  • {env:GREENTOKENS_API_KEY} reads your key from the environment, so it never sits in the file.
  • List the models you want under models. The keys are GreenTokens model IDs from the models page; the names are what opencode shows.
  • model sets the default, as provider/model-id.

Run it

export GREENTOKENS_API_KEY="sk-gt-…"
opencode
Switch between the models you listed with /models inside opencode.