Chainlit
Chainlit makes AI development frameworks work more efficiently and simply.
Tags:AI development frameworksWhat is Chainlit?
Chainlit is an open-source framework for building conversational AI applications in Python; it offers ready-made chat interfaces, event callbacks, streaming output, step-by-step display, and deployment options. Developers can retain their own models and business logic, and use a small amount of code to turn their scripts into interactive web pages or embedded assistants.
Starting from May 1, 2025, the original Chainlit team will cease active development, and the community maintainers will take over responsibility for code review, releases, and security in accordance with official maintenance protocols. Chainlit SAS does not promise any future updates, but stable versions will still be released for the repository in 2026.
Main functions
Python chat application and streaming interface
- Integrate existing Python functions into the chat interface through lifecycle callbacks such as messages, chat starts, audio, and sessions.
- Messages can be sent in a sequential stream, which is suitable for showing how a large model provides responses word by word, the status of tools, and the progress of long-running tasks.
- The Step component allows for the distinction between models, tools, and processing steps; it helps in debugging multi-stage agents and explains the execution process to users.
- Chat settings, startup prompts, modes, and chat profiles allow end-users to choose the model, role, or task configuration.
- The framework is responsible for the interaction layer; it does not come with large models that can be used freely and indefinitely. Developers must configure models or inference services separately.
Multimodal, files, and real-time audio
- The chat box supports dragging and dropping or selecting files; the backend can retrieve images, audio, videos, and regular files from the message elements.
- Developers can decide on the file type, size, parsing method, and whether to pass it to the model; they can also disable automatic file uploads.
- The audio callback can receive real-time audio blocks from the user’s microphone, which are used for voice assistants, transcription, and real-time audio processing.
- Interface elements can display images, audio, video, PDFs, tables, charts, and custom components.
- Multimodal presentation does not mean that the model possesses identical capabilities; whether the input can be understood depends on the backend model and the development code.
Integration of models, frameworks, and agents
- It can be combined with OpenAI, Mistral, LangChain, LangGraph, LlamaIndex, Semantic Kernel, AutoGen, and other Python libraries.
- The callback processor can convert certain model or framework calls into visual steps, making it easier to view the toolchain and intermediate results.
- Developers can integrate local models, cloud models, vector databases, retrieval systems, and custom business APIs.
- Chainlit does not lock in a specific model provider; costs, speeds, context, and data usage rules vary depending on the service chosen.
MCP tool connection
- Chainlit can connect to MCP servers via SSE, streaming network transmissions, or stdio, locate the tools, and incorporate the results of those calls into the agent’s workflow.
- Each WebSocket session can manage multiple named MCP connections, and these connections are terminated when the session is closed.
- Starting from version 2.7.0, it is necessary to explicitly enable the MCP function in the configuration, and it is possible to control different transmission methods separately.
- stdio launches actual child processes on the Chainlit server; it is necessary to use an executable file whitelist and to restrict user input.
- For enterprise-level MCP partnerships, it is possible to contact the project team; however, the public prices, scope of support, and duration of service have not yet been disclosed.
Installation and quick start
- Prepare a Python 3.10 or higher 3.x environment and create an isolated virtual environment.
- Install Chainlit from the Python package repository, then run the built-in examples to verify that the browser interface can be opened.
- Create a Python file, import Chainlit, and register a message callback to read the user’s messages within that callback.
- Invoke one’s own models, retrievers, or business functions, and then send the results via message objects or return them in a streaming manner.
- Run the application and enable automatic reloading during development, in order to test multiple session scenarios, as well as behavior under abnormal conditions and interruptions.
- Add authentication, persistence, logging, rate limiting, key management, and input/output security checks before going live.
- Fix the dependency versions and keep an eye on release and security announcements; do not run old versions that have not been patched for extended periods of time.
Minimum development workflow
- Define the application objectives and the allowable data range, and select the models, tools, retrieval databases, and storage systems.
- The session lifecycle is orchestrated using callbacks such as start, message, and stop for chatting.
- Wrap the time-consuming model calls in visual steps, and enable streaming output for content that can be displayed securely.
- Set allowlists, size limits, timeout values, and permission checks for files, audio, and MCP tools.
- Configure user authentication and unique user identifiers to ensure that different accounts cannot access each other’s sessions.
- Connect to the data layer and test the entire process of creating, restoring, deleting, and exporting chat data.
- Conduct load and failure testing in agent, WebSocket, and multi-instance environments that are consistent with production.
- After deployment, monitor for errors, model costs, dependency vulnerabilities, abnormal tool calls, and data retention tasks.
Input, output, and application forms
| Category | Supported content | Primary uses | Implement boundaries |
|---|---|---|---|
| Text input | Chat messages, settings, and structured operations | Q&A, agents, and business assistants | Language capabilities are determined by the backend model. |
| Multimodal input | Images, audio, video, and files | Document Q&A, visual, and voice applications | It needs to be parsed manually or passed to a compatible model. |
| Output element | Text, steps, images, PDFs, tables, charts, and custom components | Display model responses and tool results | Sensitive intermediate inferences should not be exposed directly. |
| Native web page | Chainlit chat interface | Rapid delivery of standalone AI applications | Production deployment requires self-hosting. |
| Copilot | Embed in existing websites | Add sidebars or floating assistants to the product. | Cross-domain and identity settings require additional configuration. |
| Custom frontend | Combination of React client and backend | Use own brands and interactions. | The workload for front-end development is greater. |
| Messaging platform | Teams, Slack, and Discord | Bring assistants into collaborative scenarios | Robot configuration is required for each platform. |
| Native mobile apps | The official app for end users is not available yet. | It can be accessed via responsive web pages or messaging platforms. | Web page access is not the same as a native application. |
Authentication and data persistence
| Project | Default state | Optional solutions | Deployment requirements |
|---|---|---|---|
| Access control | Apply default public setting | Authentication via password, OAuth, or request headers | It must be enabled explicitly before going live. |
| Token signature | Production secret values have not been configured automatically. | Set an independent authentication key | After a leak occurs, the sessions should be rotated and the old ones invalidated. |
| Chat history | Persistence is disabled by default. | Official, community, or custom data layers | It is necessary to define the database and retention rules. |
| File content | Processed as part of the application workflow | Object storage or custom storage client | The type, size, and access permissions need to be restricted. |
| User isolation | Determined by the application configuration. | Authenticated users are linked to the data layer. | Each user must have a unique identifier. |
| Delete and Export | There is no unified hosting strategy. | To be implemented by the application owner. | It is necessary to cover database, object, and log replicas. |
Authentication is not a security mechanism that becomes active automatically after installation; applications that have not been configured can be accessed by default. Once the data layer is enabled, it is necessary to test object-level authorization to prevent situations where login is verified but reading of threads or files across different users is still allowed.
Deployment method
| Method | Suitable scenarios | Key configurations | Main limitations |
|---|---|---|---|
| Standalone or container | Prototypes, internal tools, and small-scale applications | Production startup parameters, reverse proxy, and persistent storage | Single-node failure and limited scalability |
| Cloud Container Platform | Public services and flexible workloads | WebSocket, health checks, secret values, and logs | Cloud fees are charged separately by the platform. |
| Multi-instance deployment | High-concurrency production applications | Session affinity, shared data layer, and object storage | Load balancing requires proper handling of WebSockets. |
| Subpath deployment | Mounted in the existing site directory | Root path and proxy rewrite rules | Inconsistent paths can lead to failures in accessing resources or establishing connections. |
| Cross-domain embedding | Copilot and custom frontend | Allowed cross-domain sites, authentication, and Cookie policies | Broad cross-domain configurations increase the attack surface. |
- Chainlit relies on WebSocket, and the hosting platform as well as the reverse proxy must support connection upgrading.
- Automatic scaling usually requires session affinity; otherwise, the same user’s session state may be lost across different instances.
- The listening address must be specified within the container, and production commands should avoid automatically opening a browser on the server side.
- The third-party deployment tutorials listed in the framework documentation do not imply that the corresponding platform is free or that Chainlit is responsible for its maintenance.
Price and cost
| Package or version | Price | Billing cycle | Core benefits or quota | Suitable for users |
|---|---|---|---|---|
| Chainlit open-source framework | 0 yuan | No subscription required | Complete repository code, Python packages, and Apache 2.0 license | Developers and self-hosted teams |
| Self-hosted infrastructure | Charged by the supplier | By instance, storage, or traffic | Computing, databases, object storage, domain names, and monitoring | Production application operator |
| Models and external APIs | Charged by the model provider | Pay-as-you-go or subscription | Reasoning, embedding, voice, search, and tool services | Applications that require real AI capabilities |
| Enterprise-level MCP collaboration | Contact the team | Custom contract | Collaborations related to the enterprise MCP stack; the scope of these collaborations has not yet been made public. | Organizations with integration and support needs |
There is no confirmed unified cloud hosting package offered by a primary provider. The fact that the core framework is free does not mean that the entire AI application comes at no cost. Refund rules do not apply to free code; for refunds related to corporate partnerships, cloud resources, and model services, it is necessary to refer to the relevant contracts and the supplier’s policies.
Licenses and commercial use
- The core repository of Chainlit is licensed under the Apache License 2.0; it can be used for personal, corporate, and commercial projects, and modification as well as redistribution are permitted.
- When distributing code or derivative versions, it is necessary to include a license, retain copyright and attribution, and indicate any significant modifications made.
- Patent licensing, contribution rules, and termination conditions shall be governed by the full text of Apache 2.0; the license does not automatically grant rights to use trademarks.
- Open-source licenses do not cover the model weights, APIs, fonts, images, third-party components, and user content that are incorporated into the system.
- The software is provided as it is, without any guarantees regarding its marketability, suitability for specific purposes, or absence of infringement; the party responsible for its commercial deployment must establish its own support mechanisms and assume the associated risks.
Privacy and data responsibility
- The project’s privacy documentation states that, starting from version 2.6.1, the framework itself does not collect user data.
- This statement does not mean that the applications deployed by developers do not collect data, as models, databases, object storage systems, logs, and identity services may continue to process information.
- By default, not persisting chats can reduce the amount of data stored, but model requests, reverse proxies, and operation logs may still leave behind content or metadata.
- The application operator must provide its own privacy policy, the basis for data processing, the retention period, the procedures for deletion, and a list of third-party processors.
- When handling corporate secrets or sensitive personal data, it is necessary to choose appropriate model areas, use encrypted storage, apply the principle of least privilege, and implement auditable access controls.
- For file and audio uploads, rules regarding type, size, scanning, isolation, and automatic deletion should be established; it is not sufficient to rely solely on front-end restrictions.
Safety precautions
- The current stable version should be used, and dependency updates should be checked regularly; as of the date of verification, the current stable version on PyPI is 2.11.1.
- Previous versions prior to 2.9.4 suffered from publicly known server-side request forgery issues; deployments that utilized the SQLAlchemy data layer in particular required an upgrade.
- 2.10.1 Issues related to the restoration of WebSocket sessions and the verification of authenticated users have been fixed; the old production version should no longer be used.
- By default, the application is set to public; before deployment, it is necessary to configure authentication keys, authentication callbacks, unique user identifiers, and object-level authorization.
- The stdio approach of MCP starts a server subprocess, allowing only trusted commands and restricting parameters, working directory, network, and system permissions.
- Do not display unfiltered model reasoning chains, system prompts, keys, internal tool parameters, or error stacks to regular users.
- The size of community maintenance teams is limited, and security policy objectives do not equate to fixed repair commitments; companies should have in place independent evaluation and patching processes.
Advantages and capabilities boundaries
| Aspect | Actual advantages | Capacity boundaries |
|---|---|---|
| Development efficiency | Use Python callbacks to quickly obtain a complete chat interface. | Complex products still require front-end, back-end, and operations engineering. |
| Model compatibility | It can integrate with various Python models and agent frameworks. | Model quality, price, and privacy are not guaranteed by Chainlit. |
| Multimodal | Unified handling of files, media, and real-time audio interactions | Parsing and security policies need to be implemented by developers. |
| Flexible deployment | Web pages, embeddables, custom React, and message platforms are available as options. | WebSocket and multiple instances increase operational complexity. |
| Open-source license | Apache 2.0 is suitable for commercial self-hosting and customization. | Third-party models and assets remain subject to their respective licenses. |
| Maintenance status | The community is still releasing new versions. | The original team has stopped active development and does not guarantee any future updates. |
Summary
Chainlit is suitable for developers who wish to create chatbots, search assistants, voice applications, or MCP agents quickly using Python. Its advantages lie in its ready-to-use interaction layer, extensive integration options, and the possibility of self-hosting. When using it in production, it is necessary to take into account the community maintenance status, identity and data isolation, WebSocket deployment, third-party costs, and security upgrades as part of the long-term maintenance plan.
Guigong Network Security Registration No. 45132202000164