---
title: 配置与密钥
description: Welight CLI 的 BYOK 配置：模型提供商、判断层、朱雀与公众号密钥，以及配置文件与主题记忆。
---

CLI 不内置任何官方服务，模型、判断层与云服务都使用您自己的密钥（BYOK）。密钥保存在本地，不会上传，也不会进入模型上下文。

## 三种配置方式

**1. 配置向导（推荐）**

```bash
wl setup
```

逐步提示模型、TypeSafe 判断层、朱雀检测、公众号凭据与默认主题。密钥输入不回显，直接回车可跳过任意一项。

**2. 命令式**

```bash
# 非敏感项
wl config set theme w011
wl config set model.baseUrl https://api.deepseek.com/v1
wl config set model.model deepseek-chat
wl config get theme
wl config unset theme

# 密钥（省略 value 时遮罩输入，不进 shell 历史）
wl auth set model
wl auth set typesafe
wl auth set zhuque
wl auth set wechat-app-secret
wl auth list
```

**3. 环境变量**（适合 CI / 临时覆盖）

| 变量 | 用途 |
| --- | --- |
| `WELIGHT_MODEL_API_KEY` | 模型 API Key |
| `WELIGHT_MODEL_BASE_URL` | OpenAI 兼容接口地址 |
| `WELIGHT_MODEL` | 模型名 |
| `WELIGHT_TYPESAFE_KEY` | TypeSafe 判断层（排版推荐、体检、标题评分） |
| `WELIGHT_TYPESAFE_ENDPOINT` | 可选，覆盖判断层上游地址 |
| `WELIGHT_ZHUQUE_KEY` | 腾讯 EdgeOne / 朱雀 AIGC 检测 |
| `WELIGHT_WECHAT_APP_ID` / `WELIGHT_WECHAT_APP_SECRET` | 微信公众号 |

配置优先级：**命令行参数 > 环境变量 > 配置文件 > 内置默认值**。

## 模型提供商

`wl model` 内置了常见提供商的接口地址与模型清单，您只需选择提供商、选择模型，再填入密钥：

```bash
wl model                                      # 交互式选择
wl model --provider deepseek                  # 用默认接口与模型
wl model --provider openai --model gpt-5.6-sol
```

| 提供商 | 说明 | 密钥获取地址 |
| --- | --- | --- |
| DeepSeek | | [platform.deepseek.com/api_keys](https://platform.deepseek.com/api_keys) |
| OpenAI | | [platform.openai.com/api-keys](https://platform.openai.com/api-keys) |
| 通义千问 | 阿里云百炼平台 | [bailian.console.aliyun.com](https://bailian.console.aliyun.com) |
| 智谱 AI | | [bigmodel.cn/usercenter/proj-mgmt/apikeys](https://bigmodel.cn/usercenter/proj-mgmt/apikeys) |
| Kimi | 月之暗面 Moonshot 平台 | [platform.moonshot.cn/console/api-keys](https://platform.moonshot.cn/console/api-keys) |
| MiniMax | | [platform.minimaxi.com](https://platform.minimaxi.com) |
| 自定义接口 | 任意 OpenAI 兼容服务 | 自行填写接口地址与模型名 |

## 配置文件

非敏感项保存在项目目录的 `welight.config.json`（可用 `wl init` 生成模板）：

| 配置项 | 说明 |
| --- | --- |
| `theme` / `primaryColor` / `fontFamily` / `fontSize` / `customCSS` | 渲染样式 |
| `codeTheme` | highlight.js 代码高亮主题，`none` 关闭 |
| `watermark` | 发布是否追加文末水印 |
| `proxy` | 自建微信 API 反向代理 origin，留空直连 |
| `lint.failOn` | `wl lint` 默认失败阈值 |
| `model.provider` / `model.baseUrl` / `model.model` | 模型提供商、接口与模型名（**密钥不写这里**） |
| `typesafe.endpoint` | 覆盖判断层上游地址 |

用 `wl config` 查看当前生效配置，`wl doctor` 查看配置与密钥状态。

## 凭据文件

密钥不写入配置文件，而是保存在本地凭据文件中：

```
~/.config/welight/credentials      # 权限 0600，启动时自动加载
```

可用环境变量 `WELIGHT_HOME` 指定其他目录。凭据值不会出现在日志或模型上下文中。

## 主题记忆（预览什么发什么）

`wl render` 会记住该文章预览时使用的主题，`wl publish` 与 `wl copy` 在未显式传 `--theme` 时默认复用它：

```
优先级：--theme  >  该文件预览时记忆的主题  >  配置 theme
```

记忆保存在 `~/.config/welight/theme-memory.json`，因此**预览看到的主题就是发布时使用的主题**。
