Overview
Functions provide:- Native Python code execution
- Built-in code editor in the workspace
- Function calling and tool use capabilities
- Filter functions to modify messages
- Admin and user-level configuration
Functions are stored in the database and loaded dynamically at runtime. Admin users can create and manage functions through the web interface.
Creating Functions
Through the Web Interface
1
Navigate to Workspace
Go to Workspace → Functions in the Open WebUI interface
2
Create New Function
Click Create New Function and enter:
- ID: Unique identifier (alphanumeric and underscores only)
- Name: Display name for the function
- Description: What the function does
3
Write Function Code
Use the built-in editor to write your Python function:
4
Save and Enable
Save the function and toggle it active to make it available
Via API
Create functions programmatically:Function Types
Open WebUI supports two main types of functions:Action Functions
Perform operations and return results:Filter Functions
Modify messages before and after model processing:Valves Configuration
Valves allow functions to have configurable parameters:User Valves
Allow individual users to configure function parameters:Managing Functions
List Functions
Get Function by ID
Update Function
Toggle Function
Enable or disable a function:Delete Function
Import from URL
Load functions from GitHub or other sources:GitHub URLs are automatically converted to raw URLs. Both
blob and tree URLs are supported.Function Examples
Database Query Function
Database Query Function
API Integration Function
API Integration Function
Text Processing Function
Text Processing Function
Global vs Local Functions
Functions can be toggled between global and local scope:Best Practices
- Error Handling: Always wrap function logic in try-except blocks
- Type Hints: Use Python type hints for better documentation
- Validation: Validate inputs before processing
- Security: Never hardcode sensitive credentials
- Performance: Keep functions lightweight and fast
- Documentation: Include clear docstrings and metadata