# st.chat_message

Source: https://docs.streamlit.io/develop/api-reference/chat/st.chat_message

> **Tip**
>
> Read the [Build a basic LLM chat app](https://docs.streamlit.io/develop/tutorials/chat-and-llm-apps/build-conversational-apps) tutorial to learn how to use `st.chat_message` and `st.chat_input` to build chat-based apps.

* Function signature:

   ```python
   st.chat_message(name, *, avatar=None, width="stretch")
   ```

* Parameters:

   | name | type | default | description |
   |---|---|---|---|
   | name | "user", "assistant", "ai", "human", or str |  | The name of the message author. Can be "human"/"user" or "ai"/"assistant" to enable preset styling and avatars. Currently, the name is not shown in the UI but is only set as an accessibility label. For accessibility reasons, you should not use an empty string. |
   | avatar | Anything supported by st.image (except list), str, or None | user | The avatar shown next to the message. If avatar is None (default), the icon will be determined from name as follows:  If name is "user" or "human", the message will have a default user icon. If name is "ai" or "assistant", the message will have a default bot icon. For all other values of name, the message will show the first letter of the name.  In addition to the types supported by st.image (except list), the following strings are valid:  A single-character emoji. For example, you can set avatar="🧑‍💻" or avatar="🦖". Emoji short codes are not supported.  An icon from the Material Symbols library (rounded style) in the format ":material/icon_name:" where "icon_name" is the name of the icon in snake case. For example, icon=":material/thumb_up:" will display the Thumb Up icon. Find additional icons in the Material Symbols font library.  "spinner": Displays a spinner as an icon. |
   | width | "stretch", "content", or int |  | The width of the chat message container. This can be one of the following:  "stretch" (default): The width of the container matches the width of the parent container. "content": The width of the container matches the width of its content, but doesn't exceed the width of the parent container. An integer specifying the width in pixels: The container has a fixed width. If the specified width is greater than the width of the parent container, the width of the container matches the width of the parent container. |

* Returns: Container

    A single container that can hold multiple elements.

For an overview of the `st.chat_message` and `st.chat_input` API, check out this video tutorial by Chanin Nantasenamat ([@dataprofessor](https://www.youtube.com/dataprofessor)), a Senior Developer Advocate at Streamlit.

[Watch on YouTube](https://www.youtube.com/watch?v=4sPnOqeUDmk)
