SkillsApr 3, 2026·2 min read

Mesop — Build AI Apps Fast with Python UI

Google's Python UI framework for rapidly building AI demos and internal tools. Declarative components, hot reload. 6.5K+ stars.

TL;DR
Mesop is Google's Python UI for building AI demos and chat interfaces quickly.
§01

What it is

Mesop is an open-source Python UI framework created by Google for building AI applications quickly. It provides pre-built components for common AI app patterns -- chat interfaces, text input/output flows, and interactive dashboards -- that you compose with Python decorators and functions. The framework runs a web server and renders the UI in the browser.

It targets AI engineers and researchers who want to build interactive demos and internal tools for their models without learning frontend development.

§02

How it saves time or tokens

Mesop provides ready-made AI app patterns out of the box. A chat interface that would take hours to build in React takes a few lines of Mesop code. The framework handles state management, event handling, and rendering automatically. For AI teams, this means faster prototyping: you can wrap any model behind a user-friendly interface in minutes and share it with stakeholders.

§03

How to use

  1. Install and create an app:
pip install mesop
  1. Build a simple page:
import mesop as me

@me.page(path='/')
def home():
    me.text('Welcome to my AI App')
    me.button('Get Started', on_click=lambda e: me.navigate('/chat'))

me.run()
  1. Build a chat interface:
import mesop as me
import mesop.labs as mel

def respond(query: str, history: list) -> str:
    # Connect to your LLM here
    return f'You asked: {query}'

@me.page(path='/chat')
def chat_page():
    mel.chat(respond, title='AI Assistant')
§04

Example

import mesop as me
import mesop.labs as mel
from openai import OpenAI

client = OpenAI()

def ai_respond(query: str, history: list) -> str:
    messages = [{'role': 'user', 'content': query}]
    for h in history:
        messages.insert(0, {'role': h['role'], 'content': h['content']})
    
    response = client.chat.completions.create(
        model='gpt-4o',
        messages=messages
    )
    return response.choices[0].message.content

@me.page(path='/')
def main():
    mel.chat(
        ai_respond,
        title='AI Chat Demo',
        bot_user='Assistant'
    )
§05

Related on TokRepo

§06

Common pitfalls

  • Mesop is optimized for prototyping and internal tools. For high-traffic production apps with complex UIs, a full framework like Next.js or Reflex may be more appropriate.
  • The component library is focused on common AI app patterns. Custom or highly styled UIs may require workarounds or CSS overrides.
  • Mesop's state model re-renders the entire page on state changes. For apps with frequent updates (like streaming), this can cause flickering if not handled carefully.

Frequently Asked Questions

Is Mesop created by Google?+

Yes. Mesop is an open-source project created by Google engineers. It is used internally at Google for building AI demos and prototypes. The project is open-source and available on GitHub for anyone to use.

How does Mesop compare to Streamlit?+

Both are Python UI frameworks for building AI apps. Mesop provides a component-based architecture with explicit state management, while Streamlit uses a simpler script-based model. Mesop offers more control over layout and interaction patterns, especially for chat interfaces.

Can Mesop handle streaming LLM responses?+

Yes. Mesop supports streaming through its chat component. You can yield partial responses to update the UI progressively as the LLM generates output. This creates a natural chat experience where the user sees the response appear word by word.

Does Mesop support multi-page applications?+

Yes. You define multiple pages using the @me.page decorator with different path parameters. Mesop handles routing between pages. You can create multi-page apps with navigation menus, sidebars, and shared layout components.

Can I deploy Mesop apps to the cloud?+

Yes. Mesop apps are standard Python web servers that can be deployed to any cloud platform. Google Cloud Run, Railway, Render, and Docker-based deployments all work. The app serves on a configurable port and works behind reverse proxies.

Citations (3)
🙏

Source & Thanks

Created by Google / Mesop Dev. Licensed under Apache-2.0.

mesop — ⭐ 6,500+

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets