jupyter-ai-router
Core routing layer of Jupyter AI
What it is and what it does
jupyter_ai_router is a JupyterLab server extension that implements the foundational message routing layer for Jupyter AI. It automatically detects when new chat sessions are initialized and establishes observers on their message streams, then routes incoming messages to registered callbacks based on type—slash commands (like /help or /ai-generate) are separated from regular chat messages. Other extensions register callbacks via methods like observe_chat_init, observe_slash_cmd_msg, and observe_chat_msg to handle specific events without managing chat lifecycle themselves.
The router supports regex pattern matching for slash command handlers, allowing extensions to match exact commands or families of commands. It depends on jupyter-server and jupyterlab-chat, making it part of the Jupyter AI ecosystem rather than a standalone tool. The extension is actively maintained, supports Python 3.9 through 3.13, and is designed to be consumed by other Jupyter AI extensions via the web app settings dictionary.
Use it for:
- Build a Jupyter AI extension that responds to custom slash commands by registering a callback with observe_slash_cmd_msg and pattern matching.
- Detect when users start new chat sessions to initialize extension-specific state or connect to external services.
- Route regular chat messages to a custom handler for logging, filtering, or preprocessing before they reach the main chat interface.
- React to chat document resets (when .chat files are modified directly) to synchronize extension state with the updated document.
- Implement multi-room chat monitoring by registering separate callbacks for different room_ids to track activity across sessions.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides the core message routing layer for Jupyter AI, automatically detecting chat sessions and routing messages to registered callbacks based on message type.
Yes, if you are building a Jupyter AI extension and need to handle chat events. The router eliminates boilerplate chat lifecycle management and provides a clean callback interface. Install friction is low, maintenance is active, and the BSD license is unrestrictive. Not applicable for standalone use outside the Jupyter AI ecosystem.
Install
jupyter-ai-router on PyPI
pip
pip install jupyter-ai-routeruv
uv add jupyter-ai-routerpoetry
poetry add jupyter-ai-routerInstalling jupyter-ai-router
Before you install
Low friction install with only two runtime dependencies (jupyter-server and jupyterlab-chat). Active maintenance: released 6 days ago with recent commits.
License in practice
BSD 3-Clause License permits free use, modification, and distribution with attribution and liability disclaimer—standard permissive terms suitable for most projects.
Quickstart
pip install jupyter_ai_router
# In a Jupyter AI extension:
router = self.serverapp.web_app.settings.get("jupyter-ai", {}).get("router")
router.observe_chat_init(lambda room_id, ychat: print(f"Chat {room_id} started"))
router.observe_slash_cmd_msg("room-id", "help", lambda room_id, cmd, msg: print(msg.body))
Requires jupyter-server and jupyterlab-chat as runtime dependencies; intended for use within Jupyter AI extensions, not standalone.
Verify before relying
- Whether the router automatically persists across Jupyter server restarts or requires re-registration.
- Performance characteristics when handling many concurrent chat rooms or high message volume.
- Compatibility with custom YChat implementations beyond the standard Jupyter AI stack.
Package facts
| License | BSD 3-Clause License Copyright (c) 2025, Project Jupyter All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — jupyter-server, jupyterlab-chat |
| Maintenance | actively maintained — 6 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 92,825/month — #13,419 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: jupyter_ai_router-0.0.7-py3-none-any.whl
Keywords: jupyter, jupyterlab, jupyterlab-extension
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
jupyter-ai-chat-commandsProvides default chat commands for Jupyter AI,…
permissive · top 15,000 on PyPI
jupyterlab-chatA JupyterLab extension that adds a chat…
permissive · top 15,000 on PyPI
jupyter-ai-persona-managerProvides the foundational infrastructure for…
permissive · top 15,000 on PyPI
jupyterlab-commands-toolkitExposes JupyterLab commands to Python code and…
permissive · top 15,000 on PyPI
jupyter-aiJupyter AI is a JupyterLab extension that…
permissive · top 15,000 on PyPI
jupyter-ai-acp-clientProvides a JupyterLab extension that integrates…
permissive · top 15,000 on PyPI
semantic-routerSemantic Router routes LLM requests to…
permissive · top 15,000 on PyPI
jupyter-ai-magicsJupyter AI Magics provides a JupyterLab…
permissive · top 15,000 on PyPI
tuspyserverA FastAPI router that implements the tus…
unclear · top 15,000 on PyPI
jupyterlab_notebook_awarenessA JupyterLab extension that tracks which…
permissive · top 15,000 on PyPI