{"id":4906,"library":"chainlit","title":"Chainlit","description":"Chainlit is an open-source Python framework designed to simplify the creation of interactive user interfaces for Large Language Model (LLM) applications. It enables developers to build ChatGPT-like UIs with minimal frontend code, offering features such as chat lifecycle hooks, UI actions, real-time message streaming, and integrations with popular LLM libraries like LangChain and LlamaIndex. The library is actively maintained with frequent releases, currently at version 2.11.0.","status":"active","version":"2.11.0","language":"python","source_language":"en","source_url":"https://github.com/Chainlit/chainlit","tags":["AI","LLM","chatbot","UI","framework","conversational AI","LangChain","LlamaIndex"],"install":[{"cmd":"pip install chainlit","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Chainlit requires Python 3.10 or higher, but less than 4.0.0.","package":"python","optional":false}],"imports":[{"symbol":"cl","correct":"import chainlit as cl"},{"note":"Decorator for functions that run when a new chat session begins.","symbol":"cl.on_chat_start","correct":"@cl.on_chat_start"},{"note":"Decorator for functions that handle incoming user messages.","symbol":"cl.on_message","correct":"@cl.on_message"},{"note":"Chainlit is async-first; all `cl.Message` operations must be `await`ed to send the message and avoid returning a coroutine object.","wrong":"cl.Message(content='Hello!').send()","symbol":"cl.Message","correct":"await cl.Message(content='Hello!').send()"}],"quickstart":{"code":"import chainlit as cl\nimport os\n\n# Optional: Set CHAINLIT_AUTH_SECRET if authentication is enabled for your app\n# os.environ['CHAINLIT_AUTH_SECRET'] = os.environ.get('CHAINLIT_AUTH_SECRET', 'your_secret_key_here_for_testing')\n\n@cl.on_chat_start\nasync def start():\n    await cl.Message(\n        content=\"Welcome! I am a simple Chainlit bot. Type anything to get a response.\"\n    ).send()\n\n@cl.on_message\nasync def main(message: cl.Message):\n    # Simulate a tool's response\n    await cl.Message(author=\"Tool\", content=f\"Processing: {message.content}\", indent=1).send()\n\n    # Send back the final answer\n    await cl.Message(content=f\"You said: {message.content}\").send()\n\n# To run this:\n# 1. Save the code as `app.py`\n# 2. Run `chainlit run app.py -w` in your terminal\n","lang":"python","description":"This quickstart demonstrates a basic Chainlit application. Create a file named `app.py`, paste the code, and run it using `chainlit run app.py -w` in your terminal. This will start the Chainlit UI in your browser, where you can interact with the bot. The `@cl.on_chat_start` function sends a welcome message, and `@cl.on_message` handles incoming user messages, simulating an intermediate step and then echoing the user's input."},"warnings":[{"fix":"Execute the SQL command `ALTER TABLE steps ADD COLUMN IF NOT EXISTS modes JSONB;` on your Chainlit database before upgrading or starting applications on version 2.9.4 or higher.","message":"Chainlit v2.9.4 introduced a breaking change requiring a database migration for users employing persistence. You must run `ALTER TABLE steps ADD COLUMN IF NOT EXISTS modes JSONB;` to migrate your database.","severity":"breaking","affected_versions":">=2.9.4"},{"fix":"Always prepend `await` to asynchronous Chainlit function calls, e.g., `await cl.Message(...).send()`.","message":"Chainlit is an async-first framework. All operations that interact with the UI, such as `cl.Message().send()` or other `cl` methods that involve sending data, must be `await`ed. Failing to do so will result in a coroutine object being returned instead of the expected action, potentially leading to silent failures or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the `CHAINLIT_AUTH_SECRET` environment variable is correctly set and accessible to your Chainlit application. For OAuth, verify all `OAUTH_PROVIDER_CLIENT_ID`, `OAUTH_PROVIDER_CLIENT_SECRET`, and domain variables are correctly configured.","message":"When authentication is enabled (e.g., via `CHAINLIT_AUTH_SECRET` or OAuth), 'Invalid authentication token' errors can occur, especially when rendering images. This often indicates a missing or incorrect `CHAINLIT_AUTH_SECRET` environment variable.","severity":"gotcha","affected_versions":"All versions with authentication enabled"},{"fix":"Verify your `chainlit.toml` file is correctly formatted and located. If issues persist, ensure `load_dotenv()` (if used) is called before `import chainlit`. Consider updating to the latest Chainlit version, as such issues are often addressed.","message":"Configuration defined in `chainlit.toml` (e.g., project name, UI settings) may occasionally be ignored, particularly in certain older versions (e.g., v2.7.2). This can lead to default settings being applied instead of your custom configurations.","severity":"gotcha","affected_versions":"<2.9.4 (and potentially other versions)"}],"env_vars":null,"search_vec":"'2.11.0':73 'action':46 'activ':65 'ai':74,80 'applic':24 'build':29 'chainlit':1,2 'chat':42 'chatbot':76 'chatgpt':31 'chatgpt-lik':30 'code':37 'convers':79 'creation':14 'current':70 'design':10 'develop':27 'enabl':26 'featur':39 'framework':9,78 'frequent':68 'frontend':36 'hook':44 'integr':53 'interact':16 'interfac':18 'langchain':59,81 'languag':21 'larg':20 'librari':57,63 'lifecycl':43 'like':32,58 'llamaindex':61,82 'llm':23,56,75 'maintain':66 'messag':50 'minim':35 'model':22 'offer':38 'open':6 'open-sourc':5 'popular':55 'python':8 'real':48 'real-tim':47 'releas':69 'simplifi':12 'sourc':7 'stream':51 'time':49 'ui':33,45,77 'user':17 'version':72","created_at":"2026-04-12T16:45:46.719750+00:00","updated_at":"2026-04-17T14:30:30.794242+00:00","problems":[{"fix":"Add the Python `Scripts` directory (e.g., `C:\\Users\\YOUR_USERNAME\\AppData\\Local\\Programs\\Python\\PythonXX\\Scripts` on Windows or your virtual environment's `bin` directory) to your system's PATH. Alternatively, execute Chainlit commands using `python -m chainlit run app.py`.","cause":"The Chainlit command-line executable is not located in a directory listed in your system's PATH environment variable after installation.","error":"'chainlit' is not recognized as an internal or external command, operable program or batch file"},{"fix":"Update your application code to use `@cl.on_chat_start` to initialize your LangChain or LlamaIndex agent/chain and store it in `cl.user_session`, then retrieve it in `@cl.on_message` for message processing.","cause":"Chainlit removed the `langchain_factory`, `llama_index_factory`, and `langflow_factory` functions in newer versions to simplify its API, making older code incompatible.","error":"AttributeError: module 'chainlit' has no attribute 'langchain_factory'"},{"fix":"Ensure your deployment environment supports WebSockets. For Gunicorn with multiple workers, enable sticky sessions on your load balancer or add `transports = ['websocket']` to your `.chainlit/config.toml`. When running in Docker, use `--host 0.0.0.0` with `chainlit run`. For CORS, configure `allow_origins` in your `.chainlit/config.toml` to include your frontend's origin.","cause":"This issue commonly arises in deployment environments (e.g., Docker, Gunicorn with multiple workers, or behind a reverse proxy/load balancer) due to misconfigured WebSocket support, lack of sticky sessions, or Cross-Origin Resource Sharing (CORS) policies blocking the connection.","error":"WebSocket Connection Error / Unable to connect to server"},{"fix":"Upgrade Chainlit to a version officially compatible with LangChain `v1.x.x`. If a compatible Chainlit version is not available, you may need to manually update import statements for LangChain callbacks or refer to Chainlit's documentation for the correct way to integrate with the new LangChain API.","cause":"This error occurs when using Chainlit's `LangchainCallbackHandler` with LangChain `v1.x.x` because LangChain significantly refactored its module structure, changing the paths for its callback components.","error":"ModuleNotFoundError: No module named 'langchain.callbacks'"},{"fix":"Pin your Pydantic version to one that is known to be compatible with your installed Chainlit and other integrated library versions, for example, by adding `pydantic==2.10.1` or `pydantic<2` to your `requirements.txt` and reinstalling dependencies.","cause":"This indicates a Pydantic version incompatibility, where Chainlit or one of its dependencies (like LangChain or LlamaIndex) expects a different Pydantic API than the one installed.","error":"pydantic.errors.PydanticUserError: CodeSettings is not fully defined"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.12.0","cli_name":"chainlit","cli_version":"Chainlit, version 2.11.1","type":"library","homepage":"https://chainlit.io/","github":"https://github.com/Chainlit/chainlit","docs":"https://docs.chainlit.io/","changelog":null,"pypi":"https://pypi.org/project/chainlit/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","ai-ml","web-framework","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}