乐于分享
好东西不私藏

OpenClaw ——LiteLLM设置失败(1)

OpenClaw ——LiteLLM设置失败(1)

LiteLLM设置

参考:LiteLLM + OpenClaw:多模型 API Key 管理与模型切换实战

  1. 安装 litellm
pip install 'litellm[proxy]'
  1. 验证
(base) hmyin@hmyin-ubuntu24:~/openclaw$ litellm -vLiteLLM: Current Version = 1.83.13
  1. 配置文件litellm_config.yaml
model_list:  - model_name: gpt-4o    litellm_params:      model: openai/gpt-4o      api_key: os.environ/OPENAI_API_KEYgeneral_settings:  master_key: sk-your-secret-key  # pick any value — this is YOUR proxy password

这是官方给出的一个例子,我通过公司获得了master_key

在本地启用litellm网关,打开http://0.0.0.0:4000网页
点击LiteLLM Admin Panel on /ui
我按要求输入帐号和密码,但是始终进入不了

OpenClaw

  1. 可以得到控制面板的网址openclaw dashboard

  2. 启用OpenClaw网关openclaw gateway start

  3. 查看状态openclaw status

(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ openclaw status🦞 OpenClaw 2026.3.22 (4dcc39c) — Give me a workspace and I'll give you fewer tabs, fewer toggles, and more oxygen.◇  ◇  OpenClaw statusOverview┌──────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ Item                 │ Value                                                                                                                                                                               │├──────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤│ Dashboard            │ http://127.0.0.1:18789/                                                                                                                                                             ││ OS                   │ linux 6.11.0-26-generic (x64) · node 24.14.0                                                                                                                                        ││ Tailscale            │ off                                                                                                                                                                                 ││ Channel              │ stable (default)                                                                                                                                                                    ││ Update               │ available · pnpm · npm update 2026.4.23                                                                                                                                             ││ Gateway              │ local · ws://127.0.0.1:18789 (local loopback) · reachable 22ms · auth token · hmyin-ubuntu24 (10.26.255.218) app 2026.3.22 linux 6.11.0-26-generic                                  ││ Gateway service      │ systemd installed · enabled · running (pid 634501, state active)                                                                                                                    ││ Node service         │ systemd not installed                                                                                                                                                               ││ Agents               │ 1 · 1 bootstrap file present · sessions 1 · default main active 33d ago                                                                                                             ││ Memory               │ 0 files · 0 chunks · dirty · sources memory · plugin memory-core · vector ready · fts ready · cache on (0)                                                                          ││ Plugin compatibility │ none                                                                                                                                                                                ││ Probes               │ skipped (use --deep)                                                                                                                                                                ││ Events               │ none                                                                                                                                                                                ││ Heartbeat            │ 30m (main)                                                                                                                                                                          ││ Sessions             │ 1 active · default claude-opus-4-6 (128k ctx) · ~/.openclaw/agents/main/sessions/sessions.json                                                                                      │└──────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘Security auditSummary: 0 critical · 2 warn · 1 info  WARN Reverse proxy headers are not trusted    gateway.bind is loopback and gateway.trustedProxies is empty. If you expose the Control UI through a reverse proxy, configure trusted proxies so local-client c…    Fix: Set gateway.trustedProxies to your proxy IPs or keep the Control UI local-only.  WARN Some gateway.nodes.denyCommands entries are ineffective    gateway.nodes.denyCommands uses exact node command-name matching only (for example `system.run`), not shell-text filtering inside a command payload. - Unknown …    Fix: Use exact command names (for example: canvas.present, canvas.hide, canvas.navigate, canvas.eval, canvas.snapshot, canvas.a2ui.push, canvas.a2ui.pushJSONL, canvas.a2ui.reset). If you need broader restrictions, remove risky command IDs from allowCommands/default workflows and tighten tools.exec policy.Full report: openclaw security auditDeep probe: openclaw security audit --deepChannels┌──────────┬─────────┬────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ Channel  │ Enabled │ State  │ Detail                                                                                                                                                                       │├──────────┼─────────┼────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤└──────────┴─────────┴────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘Sessions┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬────────┬─────────┬─────────────────┬──────────────────────────────────┐│ Key                                                                                                                                │ Kind   │ Age     │ Model           │ Tokens                           │├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────┼─────────┼─────────────────┼──────────────────────────────────┤│ agent:main:main                                                                                                                    │ direct │ 33d ago │ claude-opus-4-6 │ 105k/128k (82%) · 🗄️ 100% cached │└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────┴─────────┴─────────────────┴──────────────────────────────────┘FAQ: https://docs.openclaw.ai/faqTroubleshooting: https://docs.openclaw.ai/troubleshootingUpdate available (npm 2026.4.23). Run: openclaw updateNext steps:  Need to share?      openclaw status --all  Need to debug live? openclaw logs --follow  Need to test channels? openclaw status --deep

我不清楚中间的那堆warning

  1. 更新openclaw update 更新可以指定更新稳定版本
(base) hmyin@hmyin-ubuntu24:~/openclaw$ openclaw updateUpdating OpenClaw...◇  ✓ Updating via package manager (9.7s)◇  ✓ Running doctor checks (55.68s)Update Result: OK  Root: /home/xxxxx/.nvm/versions/node/v24.14.0/lib/node_modules/openclaw  Before: 2026.3.22  After: 2026.4.23Total time: 65.48sUpdating plugins...No plugin updates needed.Restarting service...Daemon restart completed.I've seen things you wouldn't believe. Anyway, I'm updated.
  1. 直接查看当前配置pnpm exec openclaw config get看看是否保存了旧 key
(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ pnpm exec openclaw config getConfig warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)🦞 OpenClaw 2026.4.23 (a979721) — I'm not magic—I'm just extremely persistent with retries and coping strategies.error: missing required argument 'path'

这是chatgpt给的指令显然它不是很熟

  1. 重新配置 API Keypnpm exec openclaw configure
(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ pnpm exec openclaw configureConfig warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)🦞 OpenClaw 2026.4.23 (a979721) — I don't sleep, I just enter low-power mode and dream of clean diffs.┌  OpenClaw configure◇  Existing config detected ─────────╮│                                    ││  workspace: ~/.openclaw/workspace  ││  model: litellm/claude-opus-4-6    ││  gateway.mode: local               ││  gateway.port: 18789               ││  gateway.bind: loopback            ││                                    │├────────────────────────────────────╯◇  Where will the Gateway run?│  Local (this machine)◇  Select sections to configure│  Workspace◇  Workspace directory│  /home/xxxxx/.openclaw/workspaceWorkspace OK: ~/.openclaw/workspaceSessions OK: ~/.openclaw/agents/main/sessionsConfig warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)Config overwrite: /home/xxxxx/.openclaw/openclaw.json (sha256 1d2041b3228c8b42d04df53eede44e7dcd43db94d8aafcbfcac2d1915bc3aebe -> dd292ce0e44277434079d600e0ff002b74dae6b19b318ecf6477a3de79b8150b, backup=/home/xxxxx/.openclaw/openclaw.json.bak)Config warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)Updated ~/.openclaw/openclaw.json◇  Select sections to configure│  Workspace◇  Workspace directory│  /home/xxxxx/.openclaw/workspaceWorkspace OK: ~/.openclaw/workspaceSessions OK: ~/.openclaw/agents/main/sessionsConfig warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)Config overwrite: /home/xxxxx/.openclaw/openclaw.json (sha256 dd292ce0e44277434079d600e0ff002b74dae6b19b318ecf6477a3de79b8150b -> ab35d8ebef0e2f01cdacdf81e0d92829864d658a5d5ea0d568c2c79e9ff24dcd, backup=/home/xxxxx/.openclaw/openclaw.json.bak)Config warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)Updated ~/.openclaw/openclaw.json◇  Select sections to configure│  Continue◇  Control UI ────────────────────────────────────╮│                                                 ││  Web UI: http://127.0.0.1:18789/                ││  Gateway WS: ws://127.0.0.1:18789               ││  Gateway: reachable                             ││  Docs: https://docs.openclaw.ai/web/control-ui  ││                                                 │├─────────────────────────────────────────────────╯└  Configure complete.

Config warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)好可惜,千问的这个网页认证被移除了,避免每次openclaw warning就要把/home/xxxxx/.openclaw/openclaw.json文件中关于qwen-portal-auth的认证移除。

  1. 为了用上LiteLLM也是拼了老命了,我觉得我的ANTHROPIC_API_KEY设置得有问题,这个是要到官网申请吗
(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ export ANTHROPIC_API_KEY=LiteLLM-Api-Key(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ export HTTPS_PROXY=http://xxx.x.x.x:xxxx(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ export HTTP_PROXY=http://xxx.x.x.x:xxxx
  1. 我就是在瞎搞,都分不清export ANTHROPIC_API_KEY在代理前还是在代理后。再重启一下openclaw得网关openclaw gateway restart
(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ export ANTHROPIC_API_KEY=LiteLLM-Api-Key(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ openclaw gateway restartConfig warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)🦞 OpenClaw 2026.4.23 (a979721) — Pairing codes exist because even bots believe in consent—and good security hygiene.◇  Config warnings ──────────────────────────────────────────────────────────────────────╮│                                                                                        ││  - plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config  ││    entry ignored; remove it from plugins config)                                       ││                                                                                        │├────────────────────────────────────────────────────────────────────────────────────────╯Restarted systemd service: openclaw-gateway.service
  1. openclaw models auth看样子是重新认证模型的,但被我一阵捣鼓也没用上
(base) xxxxx@xxxx-ubuntu24:~/openclaw$ openclaw models authConfig warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)🦞 OpenClaw 2026.4.23 (a979721) — Making 'I'll automate that later' happen now.◇  Config warnings ──────────────────────────────────────────────────────────────────────╮│                                                                                        ││  - plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config  ││    entry ignored; remove it from plugins config)                                       ││                                                                                        │├────────────────────────────────────────────────────────────────────────────────────────╯Usage: openclaw models auth [options] [command]Manage model auth profilesOptions:  --agent <id>          Agent id for auth order get/set/clear  -h, --help            Display help for commandCommands:  add                   Interactive auth helper (provider auth or paste token)  login                 Run a provider plugin auth flow (OAuth/API key)  login-github-copilot  Login to GitHub Copilot via GitHub device flow (TTY required)  order                 Manage per-agent auth profile order overrides  paste-token           Paste a token into auth-profiles.json and update config  setup-token           Run a provider CLI to create/sync a token (TTY required)
  1. openclaw devices list没理解错的话应该是模型
(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ openclaw devices listConfig warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)🦞 OpenClaw 2026.4.23 (a979721) — Powered by open source, sustained by spite and good documentation.◇  Config warnings ──────────────────────────────────────────────────────────────────────╮│                                                                                        ││  - plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config  ││    entry ignored; remove it from plugins config)                                       ││                                                                                        │├────────────────────────────────────────────────────────────────────────────────────────╯Config warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)◇  Paired (3)┌──────────────────────────────────────────────────────────────────────┬───────────────┬────────────────────────────────────────────────────────────────────────────────────────┬───────────────┬────────────┐│ Device                                                               │ Roles         │ Scopes                                                                                 │ Tokens        │ IP         │├──────────────────────────────────────────────────────────────────────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────┼───────────────┼────────────┤│ 80d4deeeed48a384005e03856e6b0bf3e6acc203ecc0381e6a373d993e1xxxxx     │ operator      │ operator.admin, operator.read, operator.write, operator.approvals, operator.pairing    │ operator      │            ││ 8c5dde5dfbc845e1ec6b6903d66e5b5c5e06ee02d4d2ca6b112550c4d06xxxxx     │ operator      │ operator.read, operator.admin, operator.write, operator.approvals, operator.pairing    │ operator      │            ││ a026754d65bc19a6a65a9be08dd4b323274c72a7f79b517666e838b2579xxxxx     │ operator      │ operator.admin, operator.approvals, operator.pairing                                   │ operator      │            │└──────────────────────────────────────────────────────────────────────┴───────────────┴────────────────────────────────────────────────────────────────────────────────────────┴───────────────┴────────────┘
  1. openclaw health我到底在干嘛,想证明openclaw有毛病?
(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ Config warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)🦞 OpenClaw 2026.4.23 (a979721) — I've read more man pages than any human should—so you don't have to.◇  Agents: main (default)Heartbeat interval: 30m (main)Session store (main): /home/xxxxx/.openclaw/agents/main/sessions/sessions.json (1 entries)- agent:main:main (7m ago)
  1. openclaw models这是以前的配置了,天,我竟然卸载openclaw然后在机械盘上装,发现慢得要死,我又在固态盘上重新装了。ollama拉的模型在固态盘上占比太大了,我就迁移了,导致openclaw找不到ollama拉的模型了。
(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ openclaw modelsConfig warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)🦞 OpenClaw 2026.4.23 (a979721) — iMessage green bubble energy, but for everyone.◇  Config warnings ──────────────────────────────────────────────────────────────────────╮│                                                                                        ││  - plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config  ││    entry ignored; remove it from plugins config)                                       ││                                                                                        │├────────────────────────────────────────────────────────────────────────────────────────╯Config warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)Config        : ~/.openclaw/openclaw.jsonAgent dir     : ~/.openclaw/agents/main/agentDefault       : litellm/claude-opus-4-6Fallbacks (0) : -Image model   : -Image fallbacks (0): -Aliases (5)   : qwen -> qwen-portal/coder-model, deepseek-chat -> custom-api-deepseek-com/deepseek-chat, deepseek-coder -> custom-api-deepseek-com/deepseek-coder, deepseek-reasoner -> custom-api-deepseek-com/deepseek-reasoner, LiteLLM -> litellm/claude-opus-4-6Configured models (10): qwen-portal/coder-model, qwen-portal/vision-model, custom-api-deepseek-com/deepseek-chat, custom-api-deepseek-com/deepseek-coder, custom-api-deepseek-com/deepseek-reasoner, ollama/glm-4.7-flash, ollama/qwen2.5-coder:14b, ollama/qwen3:8b, litellm/claude-opus-4-6, kimi/kimi-codeAuth overviewAuth store    : ~/.openclaw/agents/main/agent/auth-profiles.jsonShell env     : offProviders w/ OAuth/tokens (1): qwen-portal (1)- anthropic effective=env:sk-8bZbh...87AVmdiA | env=sk-8bZbh...87AVmdiA | source=env: ANTHROPIC_API_KEY- anthropic-openai effective=env:sk-8bZbh...87AVmdiA | env=sk-8bZbh...87AVmdiA | source=env: ANTHROPIC_API_KEY- custom-api-deepseek-com effective=models.json:sk-8d440...63c4b563 | models.json=sk-8d440...63c4b563 | source=models.json: ~/.openclaw/agents/main/agent/models.json- kimi effective=profiles:~/.openclaw/agents/main/agent/auth-profiles.json | profiles=1 (oauth=0, token=0, api_key=1) | kimi-coding:default=h...n- litellm effective=profiles:~/.openclaw/agents/main/agent/auth-profiles.json | profiles=1 (oauth=0, token=0, api_key=1) | litellm:default=sk-2tB5R...l08QDNbA- ollama effective=profiles:~/.openclaw/agents/main/agent/auth-profiles.json | profiles=1 (oauth=0, token=0, api_key=1) | ollama:default=marker(ollama-local) | models.json=OL...EY | source=models.json: ~/.openclaw/agents/main/agent/models.json | synthetic=plugin-owned | source=plugin synthetic auth- openai effective=profiles:~/.openclaw/agents/main/agent/auth-profiles.json | profiles=1 (oauth=0, token=0, api_key=1) | openai:default=sk-8d440...63c4b563- qwen-portal effective=profiles:~/.openclaw/agents/main/agent/auth-profiles.json | profiles=1 (oauth=1, token=0, api_key=0) | qwen-portal:default=OAuth | models.json=qw...th | source=models.json: ~/.openclaw/agents/main/agent/models.jsonOAuth/token status- qwen-portal  - qwen-portal:default expired expires in 0m
  1. openclaw models list 比 openclaw models更直观
(base) xxxxx@xxxxx-ubuntu24:~/openclaw$ openclaw models listConfig warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)🦞 OpenClaw 2026.4.23 (a979721) — I don't have opinions about tabs vs spaces. I have opinions about everything else.Config warnings:- plugins.entries.qwen-portal-auth: plugin not found: qwen-portal-auth (stale config entry ignored; remove it from plugins config)Model                                      Input      Ctx      Local Auth  Tagslitellm/claude-opus-4-6                    text+image 125k     yes   yes   default,configured,alias:LiteLLMqwen-portal/coder-model                    text       125k     no    yes   configured,alias:qwenqwen-portal/vision-model                   text+image 125k     no    yes   configuredcustom-api-deepseek-com/deepseek-chat      text       125k     no    yes   configured,alias:deepseek-chatcustom-api-deepseek-com/deepseek-coder     text       125k     no    yes   configured,alias:deepseek-codercustom-api-deepseek-com/deepseek-reasoner  text       125k     no    yes   configured,alias:deepseek-reasonerollama/glm-4.7-flash                       text       125k     yes   yes   configuredollama/qwen2.5-coder:14b                   text       32k      yes   yes   configuredollama/qwen3:8b                            text       40k      yes   yes   configuredkimi/kimi-code                             text+image 256k     no    yes   configured