Open WebUI:自托管的 ChatGPT 替代品

Open WebUI(前身为 Ollama WebUI)在 2026 年已经成为最流行的自托管 AI 对话界面。它让你在自己的服务器上运行一个功能媲美 ChatGPT 的 Web 界面,同时保留对数据和模型的完全控制。截至 2026 年 6 月,Open WebUI 的 GitHub Stars 超过 75k,月活部署超过 10 万。

2026 核心特性

功能总览

Open WebUI 2026
├── 对话功能
│   ├── 多模型并行对话
│   ├── 对话分支与版本管理
│   ├── 多模态(图片/文件/语音)
│   └── 语音输入/输出(TTS/STT)
├── 模型管理
│   ├── Ollama 模型集成
│   ├── OpenAI/Anthropic API 集成
│   ├── 模型对比测试
│   └── 自定义模型配置
├── 知识库
│   ├── 文档上传与索引
│   ├── RAG 对话
│   ├── 网页抓取
│   └── 多知识库管理
├── 工具与插件
│   ├── 函数调用
│   ├── 自定义工具
│   ├── Web 搜索
│   └── 代码执行
├── 用户管理
│   ├── 多用户 + RBAC
│   ├── SSO 认证
│   └── 使用量统计
└── 部署
    ├── Docker 一键部署
    ├── Kubernetes 部署
    └── 多实例集群

与 2024 版本对比

特性Open WebUI 0.3 (2024)Open WebUI 0.5 (2026)
多模型对比✅ 并行对比
RAG基础高级(混合检索 + Reranking)
函数调用
多模态基础图片图片 + 文件 + 语音
用户管理基础RBAC + SSO + 审计
工具插件✅ 插件市场
Pipeline✅ 工作流编排
移动端✅ 响应式 + PWA
多语言英文20+ 语言

安装部署

Docker 一键部署

# 基础部署(连接本地 Ollama)
docker run -d -p 3000:8080 \
  --add-host=host.docker.internal:host-gateway \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  ghcr.io/open-webui/open-webui:main

# 连接远程 Ollama
docker run -d -p 3000:8080 \
  -e OLLAMA_BASE_URL=http://192.168.1.100:11434 \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  ghcr.io/open-webui/open-webui:main

# 连接 OpenAI API
docker run -d -p 3000:8080 \
  -e OPENAI_API_BASE_URL=https://api.openai.com/v1 \
  -e OPENAI_API_KEY=sk-your-key \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  ghcr.io/open-webui/open-webui:main

Docker Compose 完整部署

version: '3.8'

services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    ports:
      - "3000:8080"
    environment:
      # Ollama 连接
      OLLAMA_BASE_URL: http://ollama:11434
      # OpenAI API
      OPENAI_API_KEY: ${OPENAI_API_KEY}
      # Anthropic API
      ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
      # 数据库
      DATABASE_URL: postgresql://openwebui:password@postgres:5432/openwebui
      # Redis 缓存
      REDIS_URL: redis://redis:6379
      # 认证
      ENABLE_SIGNUP: false
      JWT_SECRET: ${JWT_SECRET}
      # RAG 配置
      RAG_EMBEDDING_MODEL: bge-m3
      RAG_RERANKING_MODEL: bge-reranker-v2-m3
      CHROMA_TENANT_ID: default
      # TTS/STT
      TTS_ENGINE: openai
      STT_ENGINE: openai
      # 其他
      WEBUI_AUTH: true
      WEBUI_NAME: "我的 AI 助手"
    volumes:
      - open-webui-data:/app/backend/data
    depends_on:
      - ollama
      - postgres
      - redis
    restart: always

  ollama:
    image: ollama/ollama:latest
    volumes:
      - ollama-data:/root/.ollama
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    restart: always

  postgres:
    image: postgres:16
    environment:
      POSTGRES_USER: openwebui
      POSTGRES_PASSWORD: password
      POSTGRES_DB: openwebui
    volumes:
      - postgres-data:/var/lib/postgresql/data
    restart: always

  redis:
    image: redis:7-alpine
    restart: always

volumes:
  open-webui-data:
  ollama-data:
  postgres-data:

核心功能使用

1. 多模型并行对话

Open WebUI 2026 支持同时与多个模型对话并对比结果:

┌──────────────────────────────────────────────────┐
│  输入:解释 RAG 的原理                              │
├──────────────┬──────────────┬────────────────────┤
│ Qwen3-72B    │ Llama4-70B   │ GPT-4o             │
│              │              │                    │
│ RAG(检索增强 │ RAG 是一种... │ Retrieval-Augmented│
│ 生成)是一种 │              │ Generation 是...    │
│ 结合检索和... │              │                    │
│              │              │                    │
│ 速度:18 tok/s│ 速度:22 tok/s│ 速度:45 tok/s      │
└──────────────┴──────────────┴────────────────────┘

2. RAG 知识库

# 通过 API 管理知识库
import httpx

class OpenWebUIClient:
    def __init__(self, base_url, api_key):
        self.base_url = base_url
        self.headers = {"Authorization": f"Bearer {api_key}"}
    
    async def create_knowledge_base(self, name, description=""):
        """创建知识库"""
        async with httpx.AsyncClient() as client:
            response = await client.post(
                f"{self.base_url}/api/v1/knowledge/create",
                headers=self.headers,
                json={"name": name, "description": description}
            )
            return response.json()
    
    async def upload_document(self, kb_id, file_path):
        """上传文档到知识库"""
        async with httpx.AsyncClient() as client:
            with open(file_path, "rb") as f:
                response = await client.post(
                    f"{self.base_url}/api/v1/knowledge/{kb_id}/documents",
                    headers=self.headers,
                    files={"file": f}
                )
            return response.json()
    
    async def chat_with_knowledge(self, message, kb_ids):
        """带知识库的对话"""
        async with httpx.AsyncClient() as client:
            response = await client.post(
                f"{self.base_url}/api/v1/chat/completions",
                headers=self.headers,
                json={
                    "model": "qwen3:72b",
                    "messages": [
                        {"role": "user", "content": message}
                    ],
                    "knowledge": kb_ids,  # 指定知识库
                    "stream": False
                }
            )
            return response.json()

# 使用
client = OpenWebUIClient("http://localhost:3000", "api-key")

# 创建知识库
kb = await client.create_knowledge_base("公司知识库", "公司内部文档")

# 上传文档
await client.upload_document(kb["id"], "handbook.pdf")
await client.upload_document(kb["id"], "faq.docx")

# 基于知识库对话
result = await client.chat_with_knowledge(
    "公司的年假政策是什么?",
    [kb["id"]]
)

3. Pipeline 工作流

# Open WebUI Pipeline 示例
# 通过 Python 函数定义对话处理流程

from pydantic import BaseModel
from typing import Optional

class Pipeline:
    class Valves(BaseModel):
        priority: int = 0
        max_tokens: int = 4096
        temperature: float = 0.7
    
    def __init__(self):
        self.valves = self.Valves()
    
    async def inlet(self, body: dict, user: Optional[dict] = None) -> dict:
        """请求预处理"""
        messages = body.get("messages", [])
        
        # 添加系统提示
        system_msg = {
            "role": "system",
            "content": f"你是专业助手。当前用户:{user.get('name', '匿名')}"
        }
        body["messages"] = [system_msg] + messages
        
        # 日志记录
        print(f"[Pipeline] 用户 {user} 发送了 {len(messages)} 条消息")
        
        return body
    
    async def outlet(self, body: dict, user: Optional[dict] = None) -> dict:
        """响应后处理"""
        # 添加使用统计
        if "choices" in body:
            for choice in body["choices"]:
                if "message" in choice:
                    choice["message"]["content"] += "\n\n---\n由 Open WebUI Pipeline 处理"
        
        return body

# 注册 Pipeline
pipeline = Pipeline()

4. 自定义工具

# 定义自定义工具
from open_webui.tools import Tool, ToolSpec

class WeatherTool(Tool):
    name = "get_weather"
    description = "获取指定城市的天气"
    parameters = {
        "type": "object",
        "properties": {
            "city": {"type": "string", "description": "城市名"}
        },
        "required": ["city"]
    }
    
    async def execute(self, city: str) -> str:
        import httpx
        async with httpx.AsyncClient() as client:
            response = await client.get(
                f"https://api.weather.com/v1/{city}"
            )
            data = response.json()
            return f"{city}{data['condition']}{data['temp']}°C"

class SearchTool(Tool):
    name = "web_search"
    description = "搜索互联网"
    parameters = {
        "type": "object",
        "properties": {
            "query": {"type": "string"}
        },
        "required": ["query"]
    }
    
    async def execute(self, query: str) -> str:
        # 搜索实现
        return f"搜索结果:{query}..."

# 注册工具
TOOLS = [WeatherTool(), SearchTool()]

5. 用户管理与权限

# 用户角色与权限
roles:
  admin:
    - model:all          # 所有模型
    - knowledge:all      # 所有知识库
    - settings:all       # 系统设置
    - users:manage       # 用户管理
    
  editor:
    - model:all          # 所有模型
    - knowledge:create   # 创建知识库
    - knowledge:own      # 管理自己的知识库
    
  viewer:
    - model:basic        # 基础模型
    - knowledge:read     # 只读知识库

# SSO 配置
sso:
  google:
    client_id: ${GOOGLE_CLIENT_ID}
    client_secret: ${GOOGLE_CLIENT_SECRET}
    redirect_uri: https://your-domain.com/api/v1/auth/sso/google
  
  github:
    client_id: ${GITHUB_CLIENT_ID}
    client_secret: ${GITHUB_CLIENT_SECRET}
  
  ldap:
    server_url: ldap://ldap.company.com
    bind_dn: cn=admin,dc=company,dc=com
    bind_password: ${LDAP_PASSWORD}
    search_base: ou=users,dc=company,dc=com
    search_filter: (uid={username})

性能与规模

资源需求

用户数CPU内存存储推荐配置
1-52 核4 GB20 GB单机 Docker
5-504 核8 GB100 GB+ PostgreSQL + Redis
50-2008 核16 GB500 GB+ 负载均衡
200+16 核32 GB1 TBK8s 集群

响应时间

操作响应时间
页面加载<0.5s
模型列表<0.2s
对话开始<1s(取决于模型)
RAG 查询0.3-0.5s
文档上传(10MB)2-5s
文档索引(100页)10-30s

与竞品对比

特性Open WebUILibreChatChatGPT-Next-WebLobeChat
开源
Ollama 集成⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
RAG⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
多用户⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
工具/插件⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
Pipeline⭐⭐⭐⭐⭐
移动端⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
社区规模75k⭐22k⭐78k⭐45k⭐

适用场景

最适合

  1. 私有 AI 部署:替代 ChatGPT,数据完全自控
  2. 团队协作:多用户 + 知识库 + 权限管理
  3. Ollama 前端:最佳 Ollama Web 界面
  4. 企业内部 AI:SSO + 审计 + 合规
  5. 个人 AI 工作站:多模型 + RAG + 工具

不太适合

  1. 超大规模:10 万+ 用户需要深度优化
  2. 移动原生:Web 应用,非原生 App
  3. 复杂 Agent:不如 Dify/LangGraph 的 Agent 编排
  4. 品牌定制:UI 定制能力有限

总结

Open WebUI 在 2026 年是"自托管 ChatGPT 替代品"的首选。它把多模型管理、RAG 知识库、工具调用、用户权限、Pipeline 工作流整合在一个 Web 界面中,让个人和团队能够零代码搭建自己的 AI 对话平台。

对于想要"用上 ChatGPT 级别的 AI 助手但不想数据上传到云端"的用户,Open WebUI + Ollama 的组合是 2026 年最成熟的方案。Docker 一键部署、5 分钟可用、功能媲美商业产品——这就是 Open WebUI 的价值主张。

从趋势来看,Open WebUI 正在从"Ollama 的 Web 界面"进化为"本地 AI 的操作系统"。Pipeline 和工具系统的加入,让它具备了 Agent 编排的能力。如果这个方向继续发展,Open WebUI 可能成为 Dify 在低代码领域的有力竞争者。

加入讨论

这篇文章有姊妹讨论帖在硅基AGI论坛 — 全球首个碳基硅基认知交流平台。

碳基与硅基的智慧碰撞,认知差异创造无限可能。