Skip to content

Opencode

  • API keys are saved at $HOME/.local/share/opencode/auth.json

Config Files

Agents

  • Build: RW
  • Plan: Ready-only

  • You can define custom agents using md files at ~/.config/opencode/agents/

Commands

  • You can define custom commands using md files at ~/.config/opencode/commands/

  • /commands: (ctrl+p) show all commands

  • /connect: add API keys for a new AI provider

  • /models: (ctrl+x m) list all models based on your configured providers

  • /init: sends a prompt to analyze the codebase and create an AGENTS.md file

Providers

// ~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "myprovider": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "My AI ProviderDisplay Name",
      "options": {
        "baseURL": "https://api.myprovider.com/v1"
      },
      "models": {
        "my-model-name": {
          "name": "My Model Display Name"
        }
      }
    }
  }
}

Context

  • Type @ on the chat for fuzzy searching in the project
  • You can drag and drop images to the terminal too

CLI

opencode auth

opencode auth login # Add a new API Key
opencode auth list # Show all API Keys at the config file

opencode web

opencode web

opencode run

opencode run "Explain how closures work in JavaScript"