# ConfigurableModelMiddleware

> **Class** in `deepagents_cli`

📖 [View in docs](https://reference.langchain.com/python/deepagents-cli/configurable_model/ConfigurableModelMiddleware)

Swap the model or per-call settings from `runtime.context`.

Reads two optional keys from the runtime context dict:

- `'model'` — a `provider:model` spec (e.g. `"openai:gpt-5"`).
    When present and different from the current model, the request is
    re-routed to the new model.
- `'model_params'` — a dict of extra model settings (e.g.
    `{"temperature": 0}`) that are shallow-merged into the
    request's `model_settings`.

This middleware is typically the outermost layer so it intercepts every
model call before provider-specific middleware (like
`AnthropicPromptCachingMiddleware`) runs.

## Signature

```python
ConfigurableModelMiddleware()
```

## Extends

- `AgentMiddleware`

## Methods

- [`wrap_model_call()`](https://reference.langchain.com/python/deepagents-cli/configurable_model/ConfigurableModelMiddleware/wrap_model_call)
- [`awrap_model_call()`](https://reference.langchain.com/python/deepagents-cli/configurable_model/ConfigurableModelMiddleware/awrap_model_call)

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/a827cddf72d72e4b17921b8eb445a3bfb0511cb4/libs/cli/deepagents_cli/configurable_model.py#L162)