> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute Model Call • AI Agent SDK

> execute_model_call: Execute a model call with all hooks and middleware.

# execute\_model\_call

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**MiddlewareManager**](../classes/MiddlewareManager) class in the [**middleware**](../modules/middleware) module.

Execute a model call with all hooks and middleware.

Order:

1. before\_model hooks (in order)
2. wrap\_model\_call middleware chain
3. actual model call
4. after\_model hooks (in reverse order)

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def execute_model_call(request: ModelRequest, model_fn: Callable[[ModelRequest], ModelResponse]) -> ModelResponse
```

## Parameters

<ParamField query="request" type="ModelRequest" required={true}>
  No description available.
</ParamField>

<ParamField query="model_fn" type="Callable" required={true}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="ModelResponse">
  The result of the operation.
</ResponseField>

## Uses

* `model_fn`
* `run_before_model`
* `run_after_model`
* `execute`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/hooks/middleware.py#L385">
  `praisonaiagents/hooks/middleware.py` at line 385
</Card>
