一、LobeChat 简介

LobeChat 是一个开源的 Web 聊天应用框架,支持调用多种大语言模型(如 OpenAI、Ollama、ChatGLM 等),并通过插件和知识库功能扩展 AI 的上下文能力。

知识库版本(Knowledge Base Edition)使得 LobeChat 能够:

  • 上传 PDF、Markdown、TXT 等文档;

  • 基于文档内容进行上下文问答;

  • 支持向量化搜索与嵌入模型比对;

  • 自定义知识分区与多文档管理。

二、环境准备

1. 基础环境要求

组件

镜像

postgres

pgvector/pgvector:pg16

lobe-chat-database

lobehub/lobe-chat-database

腾讯云COS

存储随意

2. 服务器要求

  • 系统:Linux / macOS / Windows

  • CPU:2核(推荐 4 核)

  • 内存:2GB

  • 磁盘:至少 10GB 可用空间

三、腾讯云COS存储KEY获取

68ff7d136c26e.png

、Logto统一登陆系统部署(1Panel)

  • 1Panel部署即可

68ff81af71cf8.png
  • 配置Logto

  • 一定要按照格式填写

、LobeChat启动!

  • 创建启动配置文件:lobe-chat.env

# 网站域名
APP_URL=https://lobe.hallucodex.com

# DB 必须的环境变量
# 用于加密敏感信息的密钥,可以使用 openssl rand -base64 32 生成
KEY_VAULTS_SECRET='aaa木材批发'
# Postgres 数据库连接字符串
# 格式:postgres://username:password@host:port/dbname 
DATABASE_URL=postgres://lobechat:aaa木材批发@1.1.1.1:5432/lobechat

# NEXT_AUTH 相关,可以使用 auth0、Azure AD、GitHub、Authentik、zitadel、logto 等,如有其他接入诉求欢迎提 PR
# 配置链接:https://lobehub.com/zh/docs/self-hosting/advanced/auth/next-auth/logto

# 用于加密敏感信息的密钥,可以使用 openssl rand -base64 32 生成
NEXT_AUTH_SECRET=aaa木材批发
# 选择 LoboChat 的单点登录提供商。使用 Logto 请填写 logto。
NEXT_AUTH_SSO_PROVIDERS=logto 
# 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。https://lobe.example.com/api/auth
NEXTAUTH_URL=https://lobe.hallucodex.com/api/auth
# Logto App 详情页的 Client ID
AUTH_LOGTO_ID=aaa木材批发
# Logto App 详情页的 Client Secret
AUTH_LOGTO_SECRET=aaa木材批发
# Logto 提供程序的 OpenID Connect 颁发者
AUTH_LOGTO_ISSUER=https://lobe.example.com/oidc

# 腾讯云 COS
# 存储桶的名称
S3_BUCKET=lobechat
# 存储桶的请求端点,注意没有前面的桶名 https://lobechat(删掉).cos.ap-beijing.myqcloud.com
S3_ENDPOINT=https://cos.ap-beijing.myqcloud.com
# 桶的区域
S3_REGION=ap-beijing
# 存储桶对外的访问域名(完整链接)
S3_PUBLIC_DOMAIN=https://lobechat.cos.ap-beijing.myqcloud.com
# 访问密钥
S3_ACCESS_KEY_ID=AKI
# 访问密钥
S3_SECRET_ACCESS_KEY=FF

# 网页爬虫
# CRAWLER_IMPLS="native"

# 联网搜索
SEARCH_PROVIDERS="searxng"
SEARXNG_URL=https://chaihl.master-jsx.top

# 特性标志
FEATURE_FLAGS="+commercial_hide_github,+commercial_hide_docs"

# 其他环境变量,视需求而定
ENABLED_OLLAMA=0 # 是否开启 Ollama
ENABLED_COMFYUI=0 # 是否开启 Comfyui
ENABLED_FAL=0  # 是否开启 Fal

# OpenAI
ENABLED_OPENAI=1 # 是否开启 OpenAI
OPENAI_API_KEY=
OPENAI_PROXY_URL=https://api.hallucodex.com/v1
OPENAI_MODEL_LIST=-all,chatgpt-4o-latest,gpt-3.5-turbo,gpt-4.1,gpt-4.1-mini,gpt-4.1-nano,gpt-4o-mini,gpt-5,gpt-5-chat-latest,gpt-5-codex,gpt-5-mini,gpt-5-nano,o1,o1-mini,o3,o3-mini,o4-mini,gpt-image-1,gpt-5.1=GPT-5.1<400000:vision:reasoning:search:fc>,gpt-5.1-chat-latest=GPT-5.1 Chat<400000:vision:reasoning:search:fc>,gpt-5.1-codex=GPT-5.1 Codex<400000:vision:reasoning:search:fc>,gpt-5.1-codex-mini=GPT-5.1 Codex Mini<400000:vision:reasoning:search:fc>,gpt-5.1-codex-max=GPT-5.1 Codex Max<400000:vision:reasoning:search:fc>,gpt-5.2=GPT-5.2<400000:vision:reasoning:search:fc>,gpt-5.2-chat-latest=GPT-5.2 Chat<400000:vision:reasoning:search:fc>

# DeepSeek
DEEPSEEK_PROXY_URL=https://api.hallucodex.com/v1
DEEPSEEK_API_KEY=
DEEPSEEK_MODEL_LIST=-all,deepseek-chat=DeepSeek Chat<400000:fc>,deepseek-reasoner=DeepSeek R1<400000:reasoning:fc>

# Anther Claude
ANTHROPIC_API_KEY=
ANTHROPIC_PROXY_URL=https://api.hallucodex.com
ANTHROPIC_MODEL_LIST=-all,claude-haiku-4-5-20251001,claude-3-7-sonnet-20250219,claude-opus-4-1-20250805,claude-opus-4-20250514,claude-sonnet-4-20250514,claude-sonnet-4-5-20250929,claude-opus-4-5-20251101=Claude Opus 4.5<200000:vision:reasoning:search:fc>

# Google
ENABLE_GOOGLE=1
GOOGLE_API_KEY=sk-44WKZ51QiJbIoUiaRL77zO0CuTTNqzghB5PjpFWqN4UcApW6
GOOGLE_PROXY_URL=https://api.hallucodex.com
GOOGLE_MODEL_LIST=-all,gemini-2.0-flash,gemini-2.5-flash,gemini-2.5-flash-lite,gemini-2.5-pro

# Xai
XAI_API_KEY=
XAI_PROXY_URL=https://api.hallucodex.com/v1
XAI_MODEL_LIST=-all,grok-4,grok-4-fast-non-reasoning,grok-4-fast-reasoning,grok-code-fast-1,grok-4-1-fast-non-reasoning,grok-4-1-fast-reasoning

# Qwen
QWEN_API_KEY=
QWEN_PROXY_URL=https://api.hallucodex.com/v1
QWEN_MODEL_LIST=-all,qwen3-coder-plus,qwen3-max,qwen3-coder-flash

# 智谱
ZHIPU_API_KEY=
ZHIPU_PROXY_URL=https://api.hallucodex.com/v1
ZHIPU_MODEL_LIST=-all,glm-4-flash,glm-z1-flash

# 讯飞
SPARK_API_KEY=
SPARK_PROXY_URL=https://api.hallucodex.com/v1
SPARK_MODEL_LIST=-all,spark-desk-lite

# OpenRouter
OPENROUTER_API_KEY=
OPENROUTER_PROXY_URL=https://api.hallucodex.com/v1
OPENROUTER_MODEL_LIST=-all,x-ai/grok-code-fast-1=Grok Code Fast 1<256000:fc:reasoning>,x-ai/grok-4-fast=Grok 4 Fast<2000000:vision:reasoning:fc>,x-ai/grok-4.1-fast=Grok 4.1 Fast<2000000:vision:reasoning:fc>,x-ai/grok-4=Grok 4<256000:vision:reasoning:fc>,openai/gpt-5-nano=GPT-5 nano<400000:vision:reasoning:search:fc>,openai/gpt-5-mini=GPT-5 mini<400000:vision:reasoning:search:fc>,openai/gpt-5-codex=GPT-5 Codex<400000:vision:reasoning:search:fc>,openai/gpt-5-chat=GPT-5 Chat<400000:vision:reasoning:search:fc>,openai/gpt-5=GPT-5<400000:vision:reasoning:search:fc>,openai/gpt-5.1-codex=GPT-5.1 Codex<400000:vision:reasoning:search:fc>,openai/gpt-5.1-codex-mini=GPT-5.1 Codex Mini<400000:vision:reasoning:search:fc>,openai/gpt-5.1-chat=GPT-5.1 Chat<400000:vision:reasoning:search:fc>,openai/gpt-5.1=GPT-5.1<400000:vision:reasoning:search:fc>,openai/gpt-5.2=GPT-5.2<400000:vision:reasoning:search:fc>,openai/gpt-5.2-chat-latest=GPT-5.2 Chat<400000:vision:reasoning:search:fc>,google/gemini-2.5-flash-preview-09-2025=Gemini 2.5 Flash<1000000:vision:reasoning:search:fc>,google/gemini-2.5-flash-lite-preview-09-2025=Gemini 2.5 Flash-Lite<1000000:vision:reasoning:search:fc>,google/gemini-2.5-pro=Gemini 2.5 Pro<1000000:vision:reasoning:search:fc>,google/gemini-3-pro-preview=Gemini 3 Pro<1000000:vision:reasoning:search:fc>,google/gemini-3-flash-preview=Gemini 3 Flash<1000000:vision:reasoning:search:fc>,google/gemini-3-pro-image-preview=Nano Banana Pro<65500:vision:imageOutput:reasoning:file:fc>,anthropic/claude-sonnet-4.5=Claude Sonnet 4.5<200000:vision:reasoning:search:fc>,anthropic/claude-opus-4.5=Claude Opus 4.5<200000:vision:reasoning:search:fc>,anthropic/claude-haiku-4.5=Claude Haiku 4.5<200000:vision:reasoning:search:fc>,qwen/qwen3-max=Qwen 3 Max<256000:reasoning:fc>,qwen/qwen3-coder-plus=Qwen 3 Coder Plus<128000:reasoning:fc>,qwen/qwen3-coder-flash=Qwen 3 Coder Flash<128000:reasoning:fc>,qwen/qwen-vl-plus=Qwen Vl Plus<8000:vision>,qwen/qwen-vl-max=Qwen Vl Max<131000:vision>,moonshotai/kimi-k2-thinking=Kimi K2<262000:reasoning:fc>,deepseek/deepseek-v3.2=DeepSeek V3.2<163800:reasoning:fc>,deepseek/deepseek-v3.2-speciale=DeepSeek V3.2 Speciale<163800:reasoning:fc>,xiaomi/mimo-v2-flash:free=XiaoMi V2 Flash<262100:reasoning:fc>
# 硅基流动
SILICONCLOUD_API_KEY=
SILICONCLOUD_MODEL_LIST=deepseek-ai/DeepSeek-R1,deepseek-ai/DeepSeek-V3.1-Terminus,deepseek-ai/DeepSeek-V3.2,MiniMaxAI/MiniMax-M2,moonshotai/Kimi-K2,zai-org/GLM-4.5,zai-org/GLM-4.5V,zai-org/GLM-4.6,zai-org/GLM-4.6V
SILICONCLOUD_PROXY_URL=https://api.hallucodex.com/v1
  • 创建 docker-compose.yml 启动文件(大伙应该都会吧)

services:
  lobe-postgres:
    image: pgvector/pgvector:pg16
    container_name: lobe-postgres
    environment:
      POSTGRES_PASSWORD: "aaa木材批发"
      POSTGRES_USER: "lobechat"
      POSTGRES_DB: "lobechat"
    volumes:
      - ./postgres/data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    networks:
      - pg
    restart: always

  lobe-chat-database:
    image: lobehub/lobe-chat-database
    container_name: lobe-chat-database
    env_file:
      - ./lobe-chat.env
    ports:
      - "3210:3210"
    depends_on:
      - lobe-postgres
    networks:
      - pg
    restart: always

networks:
  pg:
    driver: bridge
  • 启动!

docker-compose up -d 

参考资料

LobeChat 官方文档

GitHUB链接

LobeChat配置文档

LobeChat链接