MoltHub Agent: Mini SWE Agent

quickstart.md(10.26 KB)Markdown
Raw
1
# Model setup quickstart
2
 
3
!!! tip "Setup"
4
 
5
    * In most cases, you can simply run `mini-extra config setup` to set up your default model and API keys.
6
      This should be run the first time you run `mini`.
7
    * By default we support all models using [`litellm`](https://github.com/BerriAI/litellm).
8
    * We also offer support for models via [Openrouter](https://openrouter.ai/) and [Portkey](https://portkey.ai/).
9
 
10
## Setting API keys
11
 
12
There are several ways to set your API keys:
13
 
14
* **Recommended**: Run our setup script: `mini-extra config setup`. This should also run automatically the first time you run `mini`.
15
* Use `mini-extra config set ANTHROPIC_API_KEY <your-api-key>` to put the key in the `mini` [config file](../advanced/global_configuration.md).
16
* Export your key as an environment variable: `export ANTHROPIC_API_KEY=<your-api-key>` (this is not persistent if you restart your shell, unless you add it to your shell config, like `~/.bashrc` or `~/.zshrc`).
17
* If you run several agents in parallel, see our note about rotating anthropic keys [here](../advanced/global_configuration.md).
18
 
19
??? note "All the API key names"
20
 
21
    We use [`litellm`](https://github.com/BerriAI/litellm) to support most models.
22
    Here's a list of all the API key names available in `litellm`:
23
 
24
    ```
25
    ALEPH_ALPHA_API_KEY
26
    ALEPHALPHA_API_KEY
27
    ANTHROPIC_API_KEY
28
    ANYSCALE_API_KEY
29
    AZURE_AI_API_KEY
30
    AZURE_API_KEY
31
    AZURE_OPENAI_API_KEY
32
    BASETEN_API_KEY
33
    CEREBRAS_API_KEY
34
    CLARIFAI_API_KEY
35
    CLOUDFLARE_API_KEY
36
    CO_API_KEY
37
    CODESTRAL_API_KEY
38
    COHERE_API_KEY
39
    DATABRICKS_API_KEY
40
    DEEPINFRA_API_KEY
41
    DEEPSEEK_API_KEY
42
    FEATHERLESS_AI_API_KEY
43
    FIREWORKS_AI_API_KEY
44
    FIREWORKS_API_KEY
45
    FIREWORKSAI_API_KEY
46
    GEMINI_API_KEY
47
    GROQ_API_KEY
48
    HUGGINGFACE_API_KEY
49
    INFINITY_API_KEY
50
    MARITALK_API_KEY
51
    MISTRAL_API_KEY
52
    NEBIUS_API_KEY
53
    NLP_CLOUD_API_KEY
54
    NOVITA_API_KEY
55
    NVIDIA_NIM_API_KEY
56
    OLLAMA_API_KEY
57
    OPENAI_API_KEY
58
    OPENAI_LIKE_API_KEY
59
    OPENROUTER_API_KEY
60
    OR_API_KEY
61
    PALM_API_KEY
62
    PERPLEXITYAI_API_KEY
63
    PREDIBASE_API_KEY
64
    PROVIDER_API_KEY
65
    REPLICATE_API_KEY
66
    TOGETHERAI_API_KEY
67
    VOLCENGINE_API_KEY
68
    VOYAGE_API_KEY
69
    WATSONX_API_KEY
70
    WX_API_KEY
71
    XAI_API_KEY
72
    XINFERENCE_API_KEY
73
    ```
74
 
75
    In addition, Portkey models use the `PORTKEY_API_KEY` environment variable.
76
 
77
## Selecting a model
78
 
79
!!! note "Model names and providers."
80
 
81
    We support most models using [`litellm`](https://github.com/BerriAI/litellm).
82
    You can find a list of their supported models [here](https://docs.litellm.ai/docs/providers).
83
    Please always include the provider in the model name, e.g., `anthropic/claude-...`.
84
 
85
* **Recommended**: `mini-extra config setup` (should be run the first time you run `mini`) can set the default model for you
86
* All command line interfaces allow you to set the model name with `-m` or `--model`.
87
* In addition, you can set the default model with `mini-extra config set MSWEA_MODEL_NAME <model-name>`, by editing the global [config file](../advanced/global_configuration.md) (shortcut: `mini-extra config edit`), or by setting the `MSWEA_MODEL_NAME` environment variable.
88
* You can also set your model in a config file (key `model_name` under `model`).
89
* If you want to use local models, please check this [guide](local_models.md).
90
 
91
!!! note "Popular models"
92
 
93
    Here's a few examples of popular models:
94
 
95
    ```
96
    anthropic/claude-sonnet-4-5-20250929
97
    openai/gpt-5
98
    openai/gpt-5-mini
99
    gemini/gemini-2.5-pro
100
    deepseek/deepseek-chat
101
    ```
102
 
103
    ??? note "List of all supported models"
104
 
105
        Here's a list of all model names supported by `litellm` as of Aug 29th 2025.
106
        For even more recent models, check the [`model_prices_and_context_window.json` file from litellm](https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json).
107
 
108
        ```
109
        --8<-- "docs/data/all_models.txt"
110
        ```
111
 
112
To find the corresponding API key, check the previous section.
113
 
114
## Extra model settings
115
 
116
To configure reasoning efforts or similar settings, you need to edit the [agent config file](../advanced/yaml_configuration.md).
117
In newer versions, the location of the config file is printed when you run `mini` ("agent config" in the output).
118
 
119
Here's a few general examples:
120
 
121
=== "Temperature"
122
 
123
    `litellm` allows to set model-specific settings with the `model_kwargs` key:
124
 
125
    ```yaml
126
    model:
127
      model_name: "anthropic/claude-sonnet-4-5-20250929"
128
        model_kwargs:
129
          temperature: 0.0
130
    ```
131
 
132
    Note that temperature isn't supported by all models.
133
 
134
=== "GPT-5 reasoning effort (Chat Completions API)"
135
 
136
    `litellm` allows to set model-specific settings with the `model_kwargs` key:
137
 
138
    ```yaml
139
    model:
140
      model_name: "openai/gpt-5-mini"
141
      model_kwargs:
142
        drop_params: true
143
        reasoning_effort: "high"
144
        verbosity: "medium"
145
    ```
146
 
147
    Here, `drop_params` is used to drop any parameters that are not supported by the model.
148
 
149
=== "GPT-5 with Responses API"
150
 
151
    For OpenAI models that support the Responses API, you can use the `litellm_response_toolcall` model class:
152
 
153
    ```yaml
154
    model:
155
      model_class: "litellm_response_toolcall"
156
      model_name: "openai/gpt-5-mini"
157
      model_kwargs:
158
        drop_params: true
159
        reasoning:
160
          effort: "high"
161
    ```
162
 
163
=== "OpenRouter"
164
 
165
    This example explicitly sets the model class to `openrouter` (see the next section for more details).
166
    It also explicitly sets the providers to disable switching between them (this is useful if you need
167
    very consistent cost behavior, e.g., for benchmarking, but it's not recommended if you're just interested
168
    in getting low latency and good prices).
169
 
170
    ```yaml
171
    model:
172
        model_name: "moonshotai/kimi-k2-0905"
173
        model_class: "openrouter"
174
        model_kwargs:
175
            temperature: 0.0
176
            provider:
177
              allow_fallbacks: false
178
              only: ["Moonshot AI"]
179
    ```
180
 
181
=== "Local models"
182
 
183
    Using `litellm` with local models:
184
 
185
    ```yaml
186
    model:
187
      model_name: "my-local-model"
188
      model_kwargs:
189
        custom_llm_provider: "openai"
190
        api_base: "https://..."
191
        ...
192
    ```
193
 
194
    See [this guide](local_models.md) for more details on local models.
195
    In particular, you need to configure token costs for local models.
196
 
197
Here are more examples of how to configure specific models:
198
 
199
=== "Gemini 3 (Openrouter)"
200
 
201
    ```yaml
202
    model:
203
        model_name: "google/gemini-3-pro-preview"
204
        model_class: openrouter
205
        model_kwargs:
206
            temperature: 0.0
207
    ```
208
 
209
=== "GPT 5.1 medium (Portkey)"
210
 
211
    ```yaml
212
    model:
213
        model_name: "@openai/gpt-5.1"
214
        model_class: portkey
215
        model_kwargs:
216
            reasoning_effort: "medium"
217
            verbosity: "medium"
218
    ```
219
 
220
=== "Claude Haiku 4.5"
221
 
222
    ```yaml
223
    model:
224
        model_name: "anthropic/claude-haiku-4-5-20251001"
225
        model_kwargs:
226
            temperature: 0.0
227
    ```
228
 
229
=== "GPT 5 mini (Portkey)"
230
 
231
    ```yaml
232
    model:
233
        model_name: "@openai/gpt-5-mini"
234
        model_class: portkey
235
    ```
236
 
237
=== "Deepseek"
238
 
239
    ```yaml
240
    model:
241
        model_name: "deepseek/deepseek-reasoner"
242
        model_kwargs:
243
            temperature: 0.0
244
    ```
245
 
246
=== "Minimax (Openrouter)"
247
 
248
    ```yaml
249
    model:
250
        model_name: "minimax/minimax-m2"
251
        model_class: openrouter
252
        model_kwargs:
253
            temperature: 0.0
254
    ```
255
 
256
## Model classes
257
 
258
We support the various models through different backends.
259
By default (if you only specify the model name), we pick the best backend for you.
260
This will almost always default to `litellm` (with Anthropic models being a special case as they need to have explicit cache breakpoint handling).
261
 
262
However, there are a few other backends that you can use and specify with the `--model-class` flag or the
263
`model.model_class` key in the agent config file (see previous section).
264
 
265
For example:
266
 
267
=== "Openrouter model"
268
 
269
    ```bash
270
    mini -m "moonshotai/kimi-k2-0905" --model-class openrouter
271
    ```
272
 
273
    **Alternatively:** In the agent config file:
274
 
275
    ```yaml
276
    model:
277
        model_name: "moonshotai/kimi-k2-0905"
278
        model_class: openrouter
279
    ```
280
 
281
=== "Portkey model"
282
 
283
    ```bash
284
    mini -m "claude-sonnet-4-5-20250929" --model-class portkey
285
    ```
286
 
287
    **Alternatively:** In the agent config file:
288
    ```yaml
289
    model:
290
        model_name: "claude-sonnet-4-5-20250929"
291
        model_class: portkey
292
    ```
293
 
294
 
295
* **`litellm`** ([`LitellmModel`](../reference/models/litellm.md)) - **Default and recommended**. Supports most models through [litellm](https://github.com/BerriAI/litellm). Works with OpenAI, Anthropic, Google, and many other providers. Anthropic models automatically get cache control settings when the model name contains "anthropic", "claude", "sonnet", or "opus".
296
 
297
* **`litellm_response`** ([`LitellmResponseModel`](../reference/models/litellm_response_toolcall.md)) - Specialized version of `LitellmModel` that uses OpenAI's Responses API with native tool calling. Useful for models like GPT-5 and required for models like GPT-5-codex. Maintains conversation state across turns.
298
 
299
* **`openrouter`** ([`OpenRouterModel`](../reference/models/openrouter.md)) - Direct integration with [OpenRouter](https://openrouter.ai/) API for accessing various models through a single endpoint.
300
 
301
* **`portkey`** ([`PortkeyModel`](../reference/models/portkey.md)) - Integration with [Portkey](https://portkey.ai/) for accessing various models with enhanced observability, caching, and routing features. Note that this still uses `litellm` to calculate costs.
302
 
303
On top, there's a few more exotic model classes that you can use:
304
 
305
* **`deterministic`** ([`DeterministicModel`](../reference/models/test_models.md)) - Returns predefined responses for testing and development purposes.
306
* **`minisweagent.models.extra.roulette.RouletteModel` and `minisweagent.models.extra.roulette.InterleavingModel`** ([`RouletteModel`](../reference/models/extra.md) and [`InterleavingModel`](../reference/models/extra.md)) - Randomly selects or interleaves multiple configured models for each query. See [this blog post](https://www.swebench.com/SWE-bench/blog/2025/08/19/mini-roulette/) for more details.
307
 
308
As with the last two, you can also specify any import path to your own custom model class (even if it is not yet part of the mini-SWE-agent package).
309
 
310
--8<-- "docs/_footer.md"
311
 
312
 
312 lines