models.mdx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. ---
  2. title: Models
  3. description: Configuring an LLM provider and model.
  4. ---
  5. OpenCode uses the [AI SDK](https://ai-sdk.dev/) and [Models.dev](https://models.dev) to support **75+ LLM providers** and it supports running local models.
  6. ---
  7. ## Providers
  8. Most popular providers are preloaded by default. If you've added the credentials for a provider through the `/connect` command, they'll be available when you start OpenCode.
  9. Learn more about [providers](/docs/providers).
  10. ---
  11. ## Select a model
  12. Once you've configured your provider you can select the model you want by typing in:
  13. ```bash frame="none"
  14. /models
  15. ```
  16. ---
  17. ## Recommended models
  18. There are a lot of models out there, with new models coming out every week.
  19. :::tip
  20. Consider using one of the models we recommend.
  21. :::
  22. However, there are only a few of them that are good at both generating code and tool calling.
  23. Here are several models that work well with OpenCode, in no particular order. (This is not an exhaustive list nor is it necessarily up to date):
  24. - GPT 5.2
  25. - GPT 5.1 Codex
  26. - Claude Opus 4.5
  27. - Claude Sonnet 4.5
  28. - Minimax M2.1
  29. - Gemini 3 Pro
  30. ---
  31. ## Set a default
  32. To set one of these as the default model, you can set the `model` key in your
  33. OpenCode config.
  34. ```json title="opencode.json" {3}
  35. {
  36. "$schema": "https://opencode.ai/config.json",
  37. "model": "lmstudio/google/gemma-3n-e4b"
  38. }
  39. ```
  40. Here the full ID is `provider_id/model_id`. For example, if you're using [OpenCode Zen](/docs/zen), you would use `opencode/gpt-5.1-codex` for GPT 5.1 Codex.
  41. If you've configured a [custom provider](/docs/providers#custom), the `provider_id` is key from the `provider` part of your config, and the `model_id` is the key from `provider.models`.
  42. ---
  43. ## Configure models
  44. You can globally configure a model's options through the config.
  45. ```jsonc title="opencode.jsonc" {7-12,19-24}
  46. {
  47. "$schema": "https://opencode.ai/config.json",
  48. "provider": {
  49. "openai": {
  50. "models": {
  51. "gpt-5": {
  52. "options": {
  53. "reasoningEffort": "high",
  54. "textVerbosity": "low",
  55. "reasoningSummary": "auto",
  56. "include": ["reasoning.encrypted_content"],
  57. },
  58. },
  59. },
  60. },
  61. "anthropic": {
  62. "models": {
  63. "claude-sonnet-4-5-20250929": {
  64. "options": {
  65. "thinking": {
  66. "type": "enabled",
  67. "budgetTokens": 16000,
  68. },
  69. },
  70. },
  71. },
  72. },
  73. },
  74. }
  75. ```
  76. Here we're configuring global settings for two built-in models: `gpt-5` when accessed via the `openai` provider, and `claude-sonnet-4-20250514` when accessed via the `anthropic` provider.
  77. The built-in provider and model names can be found on [Models.dev](https://models.dev).
  78. You can also configure these options for any agents that you are using. The agent config overrides any global options here. [Learn more](/docs/agents/#additional).
  79. You can also define custom variants that extend built-in ones. Variants let you configure different settings for the same model without creating duplicate entries:
  80. ```jsonc title="opencode.jsonc" {6-21}
  81. {
  82. "$schema": "https://opencode.ai/config.json",
  83. "provider": {
  84. "opencode": {
  85. "models": {
  86. "gpt-5": {
  87. "variants": {
  88. "high": {
  89. "reasoningEffort": "high",
  90. "textVerbosity": "low",
  91. "reasoningSummary": "auto",
  92. },
  93. "low": {
  94. "reasoningEffort": "low",
  95. "textVerbosity": "low",
  96. "reasoningSummary": "auto",
  97. },
  98. },
  99. },
  100. },
  101. },
  102. },
  103. }
  104. ```
  105. ---
  106. ## Variants
  107. Many models support multiple variants with different configurations. OpenCode ships with built-in default variants for popular providers.
  108. ### Built-in variants
  109. OpenCode ships with default variants for many providers:
  110. **Anthropic**:
  111. - `high` - High thinking budget (default)
  112. - `max` - Maximum thinking budget
  113. **OpenAI**:
  114. Varies by model but roughly:
  115. - `none` - No reasoning
  116. - `minimal` - Minimal reasoning effort
  117. - `low` - Low reasoning effort
  118. - `medium` - Medium reasoning effort
  119. - `high` - High reasoning effort
  120. - `xhigh` - Extra high reasoning effort
  121. **Google**:
  122. - `low` - Lower effort/token budget
  123. - `high` - Higher effort/token budget
  124. :::tip
  125. This list is not comprehensive. Many other providers have built-in defaults too.
  126. :::
  127. ### Custom variants
  128. You can override existing variants or add your own:
  129. ```jsonc title="opencode.jsonc" {7-18}
  130. {
  131. "$schema": "https://opencode.ai/config.json",
  132. "provider": {
  133. "openai": {
  134. "models": {
  135. "gpt-5": {
  136. "variants": {
  137. "thinking": {
  138. "reasoningEffort": "high",
  139. "textVerbosity": "low",
  140. },
  141. "fast": {
  142. "disabled": true,
  143. },
  144. },
  145. },
  146. },
  147. },
  148. },
  149. }
  150. ```
  151. ### Cycle variants
  152. Use the keybind `variant_cycle` to quickly switch between variants. [Learn more](/docs/keybinds).
  153. ---
  154. ## Loading models
  155. When OpenCode starts up, it checks for models in the following priority order:
  156. 1. The `--model` or `-m` command line flag. The format is the same as in the config file: `provider_id/model_id`.
  157. 2. The model list in the OpenCode config.
  158. ```json title="opencode.json"
  159. {
  160. "$schema": "https://opencode.ai/config.json",
  161. "model": "anthropic/claude-sonnet-4-20250514"
  162. }
  163. ```
  164. The format here is `provider/model`.
  165. 3. The last used model.
  166. 4. The first model using an internal priority.