--- id: jupyter-ai-router version: "0.0.7" 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) license_treatment: permissive maintenance: active --- # jupyter-ai-router — Core routing layer of Jupyter AI License: permissive · Maintenance: active · Downloads: 92.8K/mo ## 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 above — 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 pip install jupyter-ai-router uv add jupyter-ai-router poetry add jupyter-ai-router ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 92.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags jupyter chat message routing, jupyterlab extension message handler, jupyter ai event callbacks, slash command routing, jupyter chat session management, jupyterlab-extension, message-routing, jupyter-ai [View on SkillFed](https://skillfed.io/packages/jupyter-ai-router) · [View on PyPI](https://pypi.org/project/jupyter-ai-router/)