Skip to main content
Functions in Open WebUI allow you to extend your language models with custom Python code that can be called during conversations. This enables your models to perform actions, fetch data, and integrate with external services.

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

Global vs Local Functions

Functions can be toggled between global and local scope:
Global functions are available to all users. Ensure they don’t expose sensitive data or operations.

Best Practices

  1. Error Handling: Always wrap function logic in try-except blocks
  2. Type Hints: Use Python type hints for better documentation
  3. Validation: Validate inputs before processing
  4. Security: Never hardcode sensitive credentials
  5. Performance: Keep functions lightweight and fast
  6. Documentation: Include clear docstrings and metadata

Next Steps

  • Learn about Tools for extended functionality
  • Explore Pipelines for request/response filtering
  • Configure Skills for reusable capabilities