> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/gradio-app/gradio/llms.txt
> Use this file to discover all available pages before exploring further.

# ChatInterface

ChatInterface is Gradio's high-level abstraction for creating chatbot UIs, and allows you to create a web-based demo around a chatbot model in a few lines of code.

## Constructor

```python theme={null}
gr.ChatInterface(
    fn,
    multimodal=False,
    chatbot=None,
    textbox=None,
    additional_inputs=None,
    additional_inputs_accordion=None,
    additional_outputs=None,
    editable=False,
    examples=None,
    example_labels=None,
    example_icons=None,
    run_examples_on_click=True,
    cache_examples=None,
    cache_mode=None,
    title=None,
    description=None,
    flagging_mode=None,
    flagging_options=("Like", "Dislike"),
    flagging_dir=".gradio/flagged",
    analytics_enabled=None,
    autofocus=True,
    autoscroll=True,
    submit_btn=True,
    stop_btn=True,
    concurrency_limit="default",
    delete_cache=None,
    show_progress="minimal",
    fill_height=True,
    fill_width=False,
    api_name=None,
    api_description=None,
    api_visibility="public",
    save_history=False,
    validator=None
)
```

### Parameters

<ParamField path="fn" type="Callable" required>
  The function to wrap the chat interface around. The function should accept two parameters: a str representing the input message and list of openai-style dictionaries representing the chat history. The function should return/yield a str (for a simple message), a supported Gradio component, a dict (for a complete openai-style message response), or a list of such messages.
</ParamField>

<ParamField path="multimodal" type="bool" default="False">
  If True, the chat interface will use a gr.MultimodalTextbox component for the input, which allows for the uploading of multimedia files. If False, the chat interface will use a gr.Textbox component for the input.
</ParamField>

<ParamField path="chatbot" type="Chatbot | None" default="None">
  An instance of the gr.Chatbot component to use for the chat interface, if you would like to customize the chatbot properties.
</ParamField>

<ParamField path="textbox" type="Textbox | MultimodalTextbox | None" default="None">
  An instance of the gr.Textbox or gr.MultimodalTextbox component to use for the chat interface, if you would like to customize the textbox properties.
</ParamField>

<ParamField path="additional_inputs" type="str | Component | list[str | Component] | None" default="None">
  An instance or list of instances of gradio components to use as additional inputs to the chatbot. The values of these components will be passed into fn as arguments in order after the chat history.
</ParamField>

<ParamField path="additional_inputs_accordion" type="str | Accordion | None" default="None">
  If a string is provided, this is the label of the gr.Accordion to use to contain additional inputs. A gr.Accordion object can be provided as well to configure other properties of the container.
</ParamField>

<ParamField path="additional_outputs" type="Component | list[Component] | None" default="None">
  An instance or list of instances of gradio components to use as additional outputs from the chat function. These must be components that are already defined in the same Blocks scope.
</ParamField>

<ParamField path="editable" type="bool" default="False">
  If True, users can edit past messages to regenerate responses.
</ParamField>

<ParamField path="examples" type="list[str] | list[MultimodalValue] | list[list] | None" default="None">
  Sample inputs for the function; if provided, appear within the chatbot and can be clicked to populate the chatbot input.
</ParamField>

<ParamField path="example_labels" type="list[str] | None" default="None">
  Labels for the examples, to be displayed instead of the examples themselves. If provided, should be a list of strings with the same length as the examples list.
</ParamField>

<ParamField path="example_icons" type="list[str] | None" default="None">
  Icons for the examples, to be displayed above the examples. If provided, should be a list of string URLs or local paths with the same length as the examples list.
</ParamField>

<ParamField path="run_examples_on_click" type="bool" default="True">
  If True, clicking on an example will run the example through the chatbot fn and the response will be displayed in the chatbot.
</ParamField>

<ParamField path="cache_examples" type="bool | None" default="None">
  If True, caches examples in the server for fast runtime in examples.
</ParamField>

<ParamField path="cache_mode" type="Literal['eager', 'lazy'] | None" default="None">
  If "eager", all examples are cached at app launch. If "lazy", examples are cached for all users after the first use by any user of the app.
</ParamField>

<ParamField path="title" type="str | I18nData | None" default="None">
  A title for the interface; if provided, appears above chatbot in large font. Also used as the tab title when opened in a browser window.
</ParamField>

<ParamField path="description" type="str | None" default="None">
  A description for the interface; if provided, appears above the chatbot and beneath the title in regular font. Accepts Markdown and HTML content.
</ParamField>

<ParamField path="flagging_mode" type="Literal['never', 'manual'] | None" default="None">
  One of "never", "manual". If "never", users will not see a button to flag an input and output. If "manual", users will see a button to flag.
</ParamField>

<ParamField path="flagging_options" type="list[str] | tuple[str, ...] | None" default="('Like', 'Dislike')">
  A list of strings representing the options that users can choose from when flagging a message. Defaults to \["Like", "Dislike"].
</ParamField>

<ParamField path="flagging_dir" type="str" default="'.gradio/flagged'">
  Path to the directory where flagged data is stored.
</ParamField>

<ParamField path="analytics_enabled" type="bool | None" default="None">
  Whether to allow basic telemetry. If None, will use GRADIO\_ANALYTICS\_ENABLED environment variable if defined, or default to True.
</ParamField>

<ParamField path="autofocus" type="bool" default="True">
  If True, autofocuses to the textbox when the page loads.
</ParamField>

<ParamField path="autoscroll" type="bool" default="True">
  If True, will automatically scroll to the bottom of the chatbot when a new message appears.
</ParamField>

<ParamField path="submit_btn" type="str | bool | None" default="True">
  If True, will show a submit button with a submit icon within the textbox. If a string, will use that string as the submit button text.
</ParamField>

<ParamField path="stop_btn" type="str | bool | None" default="True">
  If True, will show a button with a stop icon during generator executions, to stop generating. If a string, will use that string as the stop button text.
</ParamField>

<ParamField path="concurrency_limit" type="int | None | Literal['default']" default="'default'">
  If set, this is the maximum number of chatbot submissions that can be running simultaneously.
</ParamField>

<ParamField path="delete_cache" type="tuple[int, int] | None" default="None">
  A tuple corresponding \[frequency, age] both expressed in number of seconds.
</ParamField>

<ParamField path="show_progress" type="Literal['full', 'minimal', 'hidden']" default="'minimal'">
  How to show the progress animation while event is running.
</ParamField>

<ParamField path="fill_height" type="bool" default="True">
  If True, the chat interface will expand to the height of window.
</ParamField>

<ParamField path="fill_width" type="bool" default="False">
  Whether to horizontally expand to fill container fully.
</ParamField>

<ParamField path="api_name" type="str | None" default="None">
  Defines how the chat endpoint appears in the API docs.
</ParamField>

<ParamField path="api_description" type="str | None | Literal[False]" default="None">
  Description of the API endpoint.
</ParamField>

<ParamField path="api_visibility" type="Literal['public', 'private', 'undocumented']" default="'public'">
  Controls the visibility of the chat endpoint.
</ParamField>

<ParamField path="save_history" type="bool" default="False">
  If True, will save the chat history to the browser's local storage and display previous conversations in a side panel.
</ParamField>

<ParamField path="validator" type="Callable | None" default="None">
  A function that takes in the inputs and can optionally return a gr.validate() object for each input.
</ParamField>

## Example

```python theme={null}
import gradio as gr

def echo(message, history):
    return message

demo = gr.ChatInterface(
    fn=echo,
    examples=[{"text": "hello"}, {"text": "hola"}, {"text": "merhaba"}],
    title="Echo Bot"
)
demo.launch()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.