In this tutorial, we’ll walk through the steps to create a minimal LLM app.


Before getting started, make sure you have the following:

  • A working installation of Chainlit
  • Basic understanding of Python programming

Step 1: Create a Python file

Create a new Python file named in your project directory. This file will contain the main logic for your LLM application.

Step 2: Write the Application Logic

In, import the Chainlit package and define a function that will handle incoming messages from the chatbot UI. Decorate the function with the @cl.on_message decorator to ensure it gets called whenever a user inputs a message.

Here’s the basic structure of the script:
import chainlit as cl

async def main(message: cl.Message):
    # Your custom logic goes here...

    # Send a response back to the user
    await cl.Message(
        content=f"Received: {message.content}",

The main function will be called every time a user inputs a message in the chatbot UI. You can put your custom logic within the function to process the user’s input, such as analyzing the text, calling an API, or computing a result.

The Message class is responsible for sending a reply back to the user. In this example, we simply send a message containing the user’s input.

Step 3: Run the Application

To start your Chainlit app, open a terminal and navigate to the directory containing Then run the following command:

chainlit run -w

The -w flag tells Chainlit to enable auto-reloading, so you don’t need to restart the server every time you make changes to your application. Your chatbot UI should now be accessible at http://localhost:8000.


Next Steps