> ## 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 • AI Agent SDK

> execute: Execute the async middleware chain.

# execute

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

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

Execute the async middleware chain.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async def execute(request: Any, final_handler: Callable) -> Any
```

## Parameters

<ParamField query="request" type="Any" required={true}>
  The request object to pass through
</ParamField>

<ParamField query="final_handler" type="Callable" required={true}>
  The actual async operation to perform
</ParamField>

### Returns

<ResponseField name="Returns" type="Any">
  The result from the chain
</ResponseField>

## Uses

* `final_handler`
* `build_chain`
* `middleware`
* `chain`

## Used By

* [`CodeAgent.execute_code`](../functions/CodeAgent-execute_code)
* [`CodeAgent.aexecute`](../functions/CodeAgent-aexecute)
* [`MiddlewareManager.execute_model_call`](../functions/MiddlewareManager-execute_model_call)
* [`MiddlewareManager.execute_tool_call`](../functions/MiddlewareManager-execute_tool_call)
* [`HookRunner.execute_sync`](../functions/HookRunner-execute_sync)

## Source

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