模型与 API 配置

OpenClacky 支持任何 OpenAI 兼容的 LLM 提供商。可以通过配置文件或环境变量进行设置。

配置文件

路径:~/.clacky/config.yml

首次运行 openclacky 并完成 API 密钥配置向导后,该文件会自动创建。

单模型配置

- type: default
  api_key: sk-...
  base_url: https://api.anthropic.com
  model: claude-sonnet-4-5
  anthropic_format: true

双模型配置(Default + Lite)

OpenClacky 支持 default 模型(主要任务)和 lite 模型(轻量子任务)。同时配置两个模型可以优化成本:

- type: default
  api_key: sk-...
  base_url: https://api.openai.com/v1
  model: gpt-4o
  anthropic_format: false

- type: lite
  api_key: sk-...
  base_url: https://api.openai.com/v1
  model: gpt-4o-mini
  anthropic_format: false

字段说明

字段 必填 说明
type defaultlite
api_key API 密钥
base_url API 接口地址
model 模型名称(与提供商一致)
anthropic_format Anthropic 格式的 API 设为 true(Claude 模型),OpenAI 格式设为 false。默认:true

环境变量

也可以完全通过环境变量配置,无需配置文件。适合 CI/CD 或容器化部署。

Default 模型

变量名 说明
CLACKY_API_KEY API 密钥
CLACKY_BASE_URL API 地址
CLACKY_MODEL 模型名称(默认:claude-sonnet-4-5
CLACKY_ANTHROPIC_FORMAT truefalse(默认:true

Lite 模型

变量名 说明
CLACKY_LITE_API_KEY Lite 模型 API 密钥
CLACKY_LITE_BASE_URL Lite 模型 API 地址
CLACKY_LITE_MODEL Lite 模型名称(默认:claude-haiku-4
CLACKY_LITE_ANTHROPIC_FORMAT truefalse(默认:true

优先级:配置文件 > 环境变量。如果配置文件存在,环境变量只用于补充缺失的模型类型。


提供商示例

Anthropic(Claude)

- type: default
  api_key: sk-ant-...
  base_url: https://api.anthropic.com
  model: claude-sonnet-4-5
  anthropic_format: true

OpenAI

- type: default
  api_key: sk-...
  base_url: https://api.openai.com/v1
  model: gpt-4o
  anthropic_format: false

DeepSeek

- type: default
  api_key: sk-...
  base_url: https://api.deepseek.com/v1
  model: deepseek-chat
  anthropic_format: false

任何 OpenAI 兼容提供商

- type: default
  api_key: your-key
  base_url: https://your-provider.com/v1
  model: your-model-name
  anthropic_format: false

会话内切换模型

在聊天中输入 /model 可以在当前会话内切换已配置的模型。切换仅对当前会话生效——要修改默认配置,请编辑 ~/.clacky/config.yml