Pick the model or agent for a single run

headless & scripting

// what it does

-m/--model overrides the model for just this invocation using the provider/model format (anthropic/claude-sonnet-4-5), and --agent selects which agent runs it (build, plan, or a custom one). Both override your config defaults without editing a file — handy for one-off comparisons or a cheaper model in CI.

// shell

$ opencode run -m anthropic/claude-sonnet-4-5 "refactor this function"
$ opencode run --agent plan -m anthropic/claude-haiku-4-5 "summarize recent changes"

// gotcha

The provider must already be authenticated (opencode auth login) or the run fails — -m does not add credentials. The model ID must match Models.dev exactly, including the provider prefix.

// resources