Overview
Open WebUI provides several extensibility mechanisms to add custom functionality:- Pipelines - Python-based middleware for LLM interactions
- Functions/Tools - Native Python functions with code editor
- MCP Servers - Model Context Protocol integration
Pipelines Plugin Framework
Pipelines allow you to inject custom logic and Python libraries into Open WebUI’s request/response flow.What Are Pipelines?
Pipelines act as middleware between Open WebUI and LLM providers, enabling:- Rate limiting and usage controls
- Request/response filtering and modification
- Custom authentication and authorization
- Integration with monitoring tools (Langfuse, etc.)
- Translation services
- Content moderation and toxic message filtering
- Custom model routing logic
Repository
Pipelines are maintained in a separate repository: https://github.com/open-webui/pipelinesGetting Started with Pipelines
1. Clone the Pipelines Repository
2. Install Dependencies
3. Run Pipelines Server
http://localhost:9099 by default.
4. Connect to Open WebUI
In Open WebUI settings:- Go to Admin Settings → Connections
- Set OpenAI API URL to:
http://localhost:9099 - Pipelines will now intercept requests
Creating a Custom Pipeline
Pipelines are Python classes that inherit from base pipeline types.Basic Pipeline Structure
Save Your Pipeline
Save the file in thepipelines/ directory:
Pipeline Examples
Explore real-world examples in the repository: Rate Limiting:Pipeline Methods
Core Methods
__init__()- Initialize pipeline and valveson_startup()- Setup code (load models, connect to services)on_shutdown()- Cleanup codeinlet(body, user)- Intercept and modify requestsoutlet(body, user)- Intercept and modify responses
Advanced Methods
pipe()- Full control over request/response cycleon_valves_updated()- React to configuration changes
Valves (Configuration)
Valves are pipeline settings that can be modified through the UI:Native Python Functions/Tools
Open WebUI includes a built-in code editor for creating Python functions that LLMs can call.Creating a Function
- Navigate to Workspace → Tools
- Click Create New Tool
- Write your Python function
- Save and enable
Function Structure
Function Features
- Type Hints: Use Python type hints for LLM parameter understanding
- Docstrings: Provide clear descriptions for the LLM
- User Context: Access
__user__parameter for user information - Dependencies: Import standard library or installed packages
- Error Handling: Implement proper error handling
Installing Dependencies
Functions can use any Python package installed in the Open WebUI environment:pyproject.toml for permanent installation.
Function Security
Safe Mode: Enable safe mode to deactivate all functions:MCP (Model Context Protocol) Servers
MCP servers provide standardized context to LLMs through a protocol.Configuring MCP Servers
Available MCP Servers
- Filesystem: File system access
- Git: Repository interaction
- GitHub: GitHub API integration
- Slack: Slack workspace integration
- PostgreSQL: Database queries
- Brave Search: Web search
Tool/Terminal Servers
Connect external tool servers to Open WebUI.Configuration
Terminal Server
Provide terminal access for code execution:Development Best Practices
Testing
- Test locally before deploying
- Use the dev environment for iteration
- Test with various LLM providers
- Validate error handling
Error Handling
Logging
Performance
- Use async/await for I/O operations
- Cache expensive computations
- Avoid blocking operations in pipelines
- Consider rate limiting for external APIs
Security
- Validate all user inputs
- Use environment variables for secrets
- Implement proper authentication
- Sanitize outputs before returning
- Be cautious with code execution
Deployment
Production Pipelines
For production deployments:Environment Variables
Examples and Templates
Complete Pipeline Example
See the Pipelines Examples Directory for:- Authentication pipelines
- Rate limiting
- Content filtering
- Custom model routing
- Monitoring integrations
- Translation services
Function Examples
Check the Open WebUI community for shared functions:Troubleshooting
Pipeline Not Loading
- Check pipeline file syntax
- Ensure class is named
Pipeline - Verify no import errors
- Check pipelines server logs
Function Not Executing
- Verify function is enabled
- Check for syntax errors in code editor
- Ensure dependencies are installed
- Review function logs
Performance Issues
- Profile slow pipelines
- Use async operations
- Implement caching
- Consider moving logic to background tasks
Resources
Next Steps
- Review Architecture to understand integration points
- Set up Local Development environment
- Read Contributing Guidelines
- Explore example pipelines and functions
- Join the community and share your creations!