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

# autogen.messages.wrap_message

<code class="doc-symbol doc-symbol-heading doc-symbol-function" />

#### wrap\_message

```python theme={null}
wrap_message(message_cls: type[BaseMessage]) -> type[BaseModel]
```

Wrap a message class with a type field to be used in a union type

This is needed for proper serialization and deserialization of messages in a union type.<br />

<b>Parameters:</b>

| Name          | Description                                                                                                       |
| ------------- | ----------------------------------------------------------------------------------------------------------------- |
| `message_cls` | Message class to wrap<br /><br />**Type:** type\[[BaseMessage](/docs/api-reference/autogen/messages/BaseMessage)] |

<br />
