首页 教程 分类 Skills下载 关于
ZH EN JA KO
模型接入

openclaw models 模型管理命令教程

· 6 分钟

命令概述

openclaw models 命令用于管理 OpenClaw 中的所有模型配置,包括查看可用模型、测试性能、配置参数和设置默认模型。

查看模型列表

openclaw models list
Models:
  Name            Provider    Model ID              Status
  ──────────────────────────────────────────────────────────
  main            openai      gpt-4o                ✓ Active
  fast            openai      gpt-4o-mini           ✓ Active
  local           ollama      llama3.1:8b           ✓ Active
  claude          anthropic   claude-sonnet-4-20250514     ✗ No API key
  code            openai      gpt-4o                ✓ Active

Default model: main

查看可用模型

查看供应商提供的所有可用模型:

# 查看特定供应商
openclaw models available --provider openai

# 查看所有供应商
openclaw models available --all
Available models from openai:
  gpt-4o              128k context    $5.00/$15.00 per 1M tokens
  gpt-4o-mini         128k context    $0.15/$0.60 per 1M tokens
  gpt-4-turbo         128k context    $10.00/$30.00 per 1M tokens
  o1                  200k context    $15.00/$60.00 per 1M tokens

添加模型配置

openclaw models add smart-model \
  --provider openai \
  --model gpt-4o \
  --temperature 0.7 \
  --max-tokens 4096

修改模型配置

openclaw models update main --temperature 0.5
openclaw models update main --max-tokens 8192
openclaw models update main --model gpt-4o-mini

设置默认模型

openclaw models default fast

测试模型

# 快速测试
openclaw models test main

# 详细测试
openclaw models test main --verbose
Testing model: main (openai/gpt-4o)
  ✓ Connection: successful
  ✓ Response time: 1.2s
  ✓ Output quality: verified
  ✓ Streaming: working
  ✓ Token counting: accurate

  Test conversation:
    User: Hello
    AI: Hello! How can I help you today?

  Stats:
    Prompt tokens: 8
    Completion tokens: 10
    Latency: 1,200ms

性能基准测试

openclaw models benchmark main --rounds 10
Benchmark: main (openai/gpt-4o) - 10 rounds
  Avg latency: 1,350ms
  Min latency: 850ms
  Max latency: 2,100ms
  P95 latency: 1,900ms
  Avg tokens/sec: 45
  Success rate: 100%

对比测试

openclaw models compare main fast --prompt "解释相对论"

模型费用查看

openclaw models cost --period 7d
Model Cost Summary (last 7 days):
  main (gpt-4o):        $12.50  (250K tokens)
  fast (gpt-4o-mini):   $0.85   (180K tokens)
  local (llama3.1):     $0.00   (local)
  ──────────────────────────────────────
  Total:                $13.35

故障转移配置

# 设置备用模型
openclaw models set-fallback main --fallback fast
openclaw models set-fallback fast --fallback local

查看故障转移链:

openclaw models fallback-chain main
Fallback chain for 'main':
  main (openai/gpt-4o)
  → fast (openai/gpt-4o-mini)
  → local (ollama/llama3.1)

删除模型配置

openclaw models remove old-model

导入导出

openclaw models export models.json
openclaw models import models.json

总结

openclaw models 提供了完整的模型生命周期管理。从发现可用模型、配置参数、性能测试到费用监控,帮助你在多模型环境中做出最优选择。

OpenClaw 是开源免费的个人AI助手,支持 WhatsApp、Telegram、Discord 等多平台接入