Skip to main content

Overview

The models command displays all AI models available from your configured providers. Use this to:
  • Discover available models
  • Find exact model names for configuration
  • Filter models by provider
  • View model metadata and pricing

Usage

Models are displayed in the format provider/model, which is the format used in configuration files and the --model flag.

Options

provider
string
Optional provider ID to filter models. Only shows models from this provider.
--refresh
flag
Refresh the models cache from models.dev. Use this when new models are released.
--verbose
flag
Show detailed model information including pricing, context windows, and capabilities.

Examples

List All Models

Show models from all configured providers:
Output:

Filter by Provider

Show only Anthropic models:
Output:

Show Detailed Information

View model metadata:
Output:

Refresh Model Cache

Update the cached model list from models.dev:
This fetches the latest model information and is useful when:
  • New models are released
  • Model pricing changes
  • You add a new provider

Model Format

All models follow the provider/model format:
Examples:
  • anthropic/claude-4.5-sonnet
  • openai/gpt-4o
  • google/gemini-2.0-flash-exp
  • opencode/claude-max

Using Model Names

In Configuration

Set default model in opencode.json:

With CLI Flags

Specify model when starting OpenCode:
Or with the run command:

Model Switching

Switch models mid-session using the /model command:

Provider Order

Models are displayed in a specific order:
  1. OpenCode providers (e.g., opencode/claude-max) - shown first
  2. Other providers - alphabetically by provider ID
Within each provider, models are alphabetically sorted.

Model Information

With --verbose, you can see:
  • Context window: Maximum input tokens
  • Max tokens: Maximum output tokens
  • Pricing: Input and output costs per 1K tokens
  • Capabilities: Features like vision, function calling, streaming
  • Modalities: Supported input/output types

Understanding Provider IDs

Common provider IDs:

Models.dev

OpenCode uses models.dev as the central registry for AI models. This provides:
  • Unified model metadata
  • Up-to-date pricing information
  • Capability and feature information
  • Support for 50+ providers

Cache Management

Model information is cached locally for performance. The cache:
  • Updates automatically on first run each day
  • Can be manually refreshed with --refresh
  • Is stored in ~/.local/share/opencode/models.json

Provider Configuration

Before using models from a provider, you must authenticate:
See the auth command for authentication details.

Filtering and Searching

While the command doesn’t have built-in search, you can use standard Unix tools:

Search by Name

Count Models

Show Specific Range

Troubleshooting

No Models Shown

Problem: Command returns empty or shows no models Solutions:
  • Run opencode models --refresh to update cache
  • Check internet connectivity
  • Verify you’ve authenticated with opencode auth login
  • Check provider is enabled in config

Provider Not Found

Problem: Provider not found: <provider> Solutions:
  • Check provider ID spelling
  • Run opencode models without arguments to see available providers
  • Ensure provider is configured in opencode.json
  • Authenticate with the provider: opencode auth login

Models Out of Date

Problem: New models missing from list Solutions:
  • Run opencode models --refresh
  • Check models.dev for latest models
  • Verify OpenCode is up to date: opencode upgrade

Environment Variables

The models command respects these environment variables:

auth

Authenticate with model providers

Configuration

Configure default models

Providers

Learn about available providers

TUI

Using models in the interface