跳到主要内容
Claw101
第6章 · 免费预计阅读 1 分钟

模型配置

模型配置

OpenClaw 支持内置 Provider 和自定义 Provider,可按成本与效果组合使用。

常见内置 Provider

  • anthropic(Claude)
  • openai(GPT)
  • openrouter
  • minimax
  • zai
  • moonshot
  • ollama

多模型与别名

{
  agents: {
    defaults: {
      models: {
        "anthropic/claude-opus-4-6": { alias: "opus" },
        "anthropic/claude-sonnet-4-5": { alias: "sonnet" },
        "openai/gpt-5.2": { alias: "gpt" },
        "deepseek/deepseek-chat": { alias: "ds" },
      },
      model: {
        primary: "anthropic/claude-sonnet-4-5",
        fallbacks: ["minimax/MiniMax-M2.1"],
      },
    },
  },
}

聊天中快速切换:

/model opus
/model gpt
/model ds

自定义 Provider(重点)

{
  models: {
    mode: "merge",
    providers: {
      "my-provider": {
        baseUrl: "https://api.example.com/v1",
        apiKey: "${MY_API_KEY}",
        api: "openai-responses",
        models: [{
          id: "model-name",
          name: "显示名称",
          reasoning: false,
          input: ["text"],
          contextWindow: 128000,
          maxTokens: 8192,
        }],
      },
    },
  },
}

Codex 系列必须使用 openai-responses,不要误用 openai-completions

Token 与成本查看

openclaw status
openclaw dashboard

如需成本可视化,建议在消息前缀显示模型名:

{
  messages: {
    responsePrefix: "[{model}]",
  },
}

学完这章想实战?加入社群获得 $50 算力额度 + 实时答疑

加入社群 ¥99