> ## 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.

# After Model • AI Agent SDK

> after_model: Decorator to mark a function as an after_model hook.

# after\_model

<div className="flex items-center gap-2">
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**middleware**](../modules/middleware) module.

Decorator to mark a function as an after\_model hook.

The function receives a ModelResponse and should return a (possibly modified) ModelResponse.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def after_model(func: AfterModelFn) -> AfterModelFn
```

## Parameters

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

### Returns

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

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
@after_model
    def log_response(response):
        print(f"Model returned: {response.content[:50]}")
        return response
```

## Source

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