Skip to content

OpenRouter integration filters for Open WebUI - expose advanced features through user-friendly toggles

Notifications You must be signed in to change notification settings

admirito/openwebui-openrouter-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenRouter Integration for Open WebUI

Filters and pipes that expose OpenRouter’s advanced features through Open WebUI’s interface. Provides user-friendly toggles for speed optimization, reasoning modes, web search, structured outputs, and image generation without requiring model name modifications.

Installation

Download openrouter-functions.json from GitHub Releases, then import into Open WebUI:

  1. In Open WebUI, click the profile iconAdmin PanelFunctions tab
  2. Click Import button and select the downloaded openrouter-functions.json
  3. Confirm the import (refresh the page if functions don’t appear immediately)
  4. Enable all OpenRouter functions in the Functions list
  5. IMPORTANT: For each filter, click the ... menu → enable Global toggle
    • This makes filter toggles appear automatically in all chats without requiring a workspace

Why OpenRouter Features Matter

OpenRouter offers powerful capabilities beyond basic LLM access:

  • Image Generation: Generate and edit images through models like Gemini and GPT-5 Image
  • Performance Routing: Optimize for throughput (:nitro), cost (:floor), or latency across multiple providers serving the same model
  • Extended Reasoning: Enable step-by-step thinking for complex queries (:thinking variant or reasoning parameter)
  • Real-time Web Search: Access current information via native provider search or Exa API (:online variant)
  • Structured Outputs: Force valid JSON responses with optional schema validation
  • Provider Control: Fine-grained routing, privacy modes, fallbacks, and cost limits
  • Automatic Fallbacks: Provider-level redundancy without configuration

Model Variants vs Parameters

OpenRouter supports two approaches for feature activation:

Model name suffixes (e.g., openai/gpt-4o:nitro, claude-3.5-sonnet:online):

  • Convenient shorthand for common features
  • Issue: Open WebUI Filter functions validate model names against known models before processing. Models with :variant suffixes are rejected at this validation stage, preventing the request from reaching OpenRouter.

Request body parameters (e.g., provider.sort = "throughput", plugins = [{"id": "web"}]):

  • Equivalent functionality without modifying model names
  • Compatible with Open WebUI’s model validation
  • More flexible - can combine multiple features in one request
  • This is the approach we use

Open WebUI Integration

Open WebUI supports multiple extension methods (Pipe, Filter, Action functions). We use:

Filter functions for request modification:

  • Provide UI toggles for users (per-conversation enable/disable)
  • Intercept requests before they reach OpenRouter (inlet hook)
  • Support admin-configurable settings (Valves) for customization
  • Allow global settings (filters without toggles, always applied)

Pipe functions for custom models:

  • Appear as selectable models in the Open WebUI interface
  • Handle complete request/response cycles (e.g., image generation)
  • Support streaming responses and status updates

Implementation Approach

Filters (in filters/ directory):

  • Toggle Filters: User-controlled per-conversation switches for dynamic features (speed optimization, reasoning modes, web search, structured outputs)
  • Global Settings Filter: Admin-configured settings applied to all requests (privacy mode, cost limits, provider preferences)

Pipes (in pipes/ directory):

  • Custom models for specialized tasks (e.g., image generation with automatic model selection)

All functions use OpenRouter’s parameter-based API to avoid model name validation issues.

Development

Format code:

uv run black filters/ pipes/

Export functions to Open WebUI import format:

uv run python export.py

This generates openrouter-functions.json ready for import into Open WebUI.

Sharing to Community

To share functions to openwebui.com: import openrouter-functions.json into your Open WebUI instance, then use the share button on each function. Copy content from COMMUNITY_README.md into the README field on the sharing page.

Cache Management

Generated images are cached at /app/backend/data/cache/image_generations/.

# Delete images older than 30 days
find /app/backend/data/cache/image_generations/ -name "*.png" -mtime +30 -delete

References

OpenRouter Docs
https://openrouter.ai/docs
Open WebUI Functions
https://docs.openwebui.com/features/plugin/functions

About

OpenRouter integration filters for Open WebUI - expose advanced features through user-friendly toggles

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages