AI Configuration

Configure AI models, providers, and custom agents.

Model Selection

Quick Model Switcher

A compact model switcher is embedded directly in the chat interface. Click the model name in the prompt area or chat header to open the quick-select sheet:

ItemDescription
HeaderThe active model with its provider and context size. Models with variants show a variant dropdown: Default or a named tier (e.g., fast or pro).
FavoritesStarred models, listed first. Click the star on any row to add or remove a favorite. The active model shows a checkmark.
RecentYour last 10 used models, excluding favorites. The trash icon removes one from the list. With no favorites or recents, the first few available models are listed instead.
More modelsOpens the full model browser when you need a model not in recents or favorites.

Favorites, recents, and variant choices are stored in OpenCode's own state file (.opencode/state/opencode/model.json in the workspace), so they are shared with the OpenCode TUI and survive Manager restarts. The same preferences apply on every server you open, local or linked, while the picker only lists models in the current server's catalog. The active model itself is not persisted. Without a pick of your own, it resolves the same way the OpenCode TUI does: the current agent's model, then the model set in opencode.json, then your most recent available model, then the first available model. A model you pick is kept per location and agent (per session and agent inside a session) until the page is reloaded.

Per-Agent and Per-Session Models

Each agent can declare its own model in opencode.json, which becomes that agent's default. When you open an existing session, the model, agent, and variant used by its last message are restored from the session itself, so switching between sessions keeps each one's selection.

Full Model Browser

To browse all available models:

  1. Click More models in the quick-select popover
  2. Filter by provider or search by name
  3. Click a model to select it

Changing Models Mid-Session

You can switch models at any point during a session without losing context. The new model is used for all subsequent messages.

Providers

Configure API keys or OAuth for AI providers.

Providers Settings

API Key Method

  1. Go to Settings > Providers
  2. Select a provider (OpenAI, Anthropic, etc.)
  3. Enter your API key
  4. Click Save

OAuth Method

For providers that support OAuth (Anthropic, GitHub Copilot):

  1. Go to Settings > Providers
  2. Under OAuth Providers, click Connect (or Reconnect) on the provider
  3. In the Connect to dialog, choose an authentication method
  4. Complete the flow:
    • Browser-based methods open the provider's sign-in page
    • Code-based methods show an Authorization Code field; paste the code and click Complete Authentication

Testing Credentials

After adding credentials:

  1. Open a chat session and click the model selector
  2. Models from that provider should appear
  3. Select a model and try sending a message

If models don't appear, verify your API key and check for errors.

Custom Models

Add models that are not in a provider's catalog, such as an OpenAI-compatible endpoint you host:

  1. Go to Settings → OpenCode Config → Models
  2. Click Add Model
  3. Pick an existing provider, or turn on Create new provider and set its Provider Type (API endpoint or NPM package), Provider ID, Display Name, and Base URL or NPM Package. For an API provider, an optional API Key (for discovery) fetches the endpoint's model list.
  4. Set the model's Config Key, Provider Model ID, and Display Name, plus optional family, status, release date, and context, input, and output limits
  5. Click Create

Models are written under provider.<id>.models in the OpenCode configuration.

Custom Agents

Create specialized AI agents with custom configurations.

Creating an Agent

  1. Go to Settings → OpenCode Config → Agents

  2. Click Add Agent

  3. Configure:

    • Agent Name - Identifier for the agent (e.g., my-agent)
    • Description - What this agent does
    • Prompt - The system prompt that defines the agent's behavior
    • Mode - Subagent, Primary, or All
    • Temperature, Top P - Optional sampling settings
    • Model - Model to use; leave empty for the OpenCode default
    • Tools Configuration - Toggle the built-in Write, Edit, Bash, and Web Fetch tools
    • Permissions - Ask, Allow, or Deny for Edit, Bash, and Web Fetch
    • Disable agent - Keep the definition but prevent the agent from being used
  4. Click Create (or Update when editing)

System Prompt Tips

Write effective system prompts:

You are a code review expert specializing in TypeScript and React.

When reviewing code:
1. Check for type safety issues
2. Look for potential bugs
3. Suggest performance improvements
4. Ensure consistent code style

Be concise but thorough. Prioritize issues by severity.

Tool Permissions

The Tools Configuration section toggles each built-in tool on or off:

  • Write - Create and modify files
  • Edit - Edit existing files
  • Bash - Run shell commands
  • Web Fetch - Fetch content from the web

The Permissions section sets each of Edit, Bash, and Web Fetch to Ask, Allow, or Deny.

This is useful for:

  • Security-focused agents that shouldn't modify files
  • Research agents that only need read access
  • Specialized agents for specific tasks

Using Custom Agents

  1. Start a new session
  2. Click the agent selector
  3. Choose your custom agent
  4. Chat with the specialized agent

Context Usage

Monitor token usage with the context indicator:

  • Shows the tokens used and, when the model's context limit is known, the percentage of that limit
  • Computes the total the same way the OpenCode TUI does: the input, output, reasoning, cache read, and cache write tokens reported by the last assistant message that recorded usage, counting from the most recent completed compaction (a compaction resets the count)
  • Shows the percentage only when the model's context limit is known, rounded to the nearest percent
  • Updates as the conversation grows
  • Colored green below 50%, yellow below 80%, and red at 80% or more

Managing Context

When context is running low:

  1. Use /compact to summarize history
  2. Start a new session with /new
  3. Be more concise in prompts
  4. Remove unnecessary file mentions

Context Limits

Different models have different context limits. Check your provider's documentation for exact limits per model.