Copied to clipboard

OpenCode Setup

Launch OpenCode through tapes to capture every conversation, with your choice of provider.

Provider guidance

This guide covers OpenCode with OpenAI models. For Anthropic, Claude Code is the recommended path; for local models, see the Ollama guide.

Quick Start

The simplest way to capture OpenCode conversations:

tapes start opencode

On first run, tapes prompts you to pick a provider and model, saving your choice to ~/.tapes/config.toml. Skip the prompt with flags:

# OpenAI
tapes start opencode --provider openai --model gpt-5.2-codex

# Local models via Ollama
tapes start opencode --provider ollama --model qwen3-coder:30b

This automatically:

  • Starts the tapes daemon with auto-selected ports
  • Points OpenCode's selected provider at the proxy
  • Tags all conversations with agent_name: opencode
  • Restores your original OpenCode config when you exit

Switching models inside OpenCode won't be captured — use a separate tapes start opencode session per provider/model.

Manual Setup

For control over ports and storage, run the proxy yourself and point OpenCode at it.

1. Start tapes

tapes serve \
  --provider openai \
  --upstream "https://api.openai.com/v1" \
  --proxy-listen "0.0.0.0:8080" \
  --postgres "postgres://tapes:tapes@localhost:5432/tapes?sslmode=disable"

2. Point OpenCode at the proxy

Edit ~/.config/opencode/opencode.json (create it if needed), then restart OpenCode:

{
  "provider": {
    "openai": {
      "options": {
        "baseURL": "http://localhost:8080"
      }
    }
  }
}

To stop capturing, remove the baseURL option (or delete the file) and restart OpenCode.

Verify It's Working

After sending a message, confirm the session was captured:

tapes sessions

Your new session appears in the list, tagged agent_name: opencode.

Troubleshooting

Conversations aren't captured despite correct config

Stored OAuth credentials in ~/.local/share/opencode/auth.json silently override explicit provider config. tapes start opencode handles this for you; for manual setup, remove them:

rm ~/.local/share/opencode/auth.json

Then restart OpenCode so it uses the API key from your config.

Config not applied

Confirm the file is valid and that you restarted OpenCode after editing it:

cat ~/.config/opencode/opencode.json

Next Steps

Everything you capture is queryable the same way, whatever agent produced it:

Last updated: