> This page is for version v1 (default).
> For other versions, use one of these documentation indexes:
> - v1 (default): https://docs.butterix.com/llms.txt
> - v0: https://docs.butterix.com/v0/llms.txt

> For the MDX source of any page, append .mdx to the page URL.
> For a complete documentation index, see https://docs.butterix.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.butterix.com/_mcp/server.
> If something on this page is wrong or missing, POST JSON {"page": "<page URL>", "message": "<what is wrong>"} to https://docs.butterix.com/_biti/feedback/agent.

# 更新 Ask AI 设置

`PUT /sites/{site}/ai`

需要 `admin` 角色。只更新传入的字段。

- 切换 `provider` 且未传 `model` 时，模型重置为该提供商的默认模型；未传 `apiKey` 时清除原密钥（密钥与提供商绑定）。
- `apiKey: null` 清除站点密钥，回退到平台密钥（如有）。密钥以 AES-256-GCM 加密存储。
- `effort` 的可选档位由模型决定（见 [模型列表](https://docs.butterix.com/api-reference/ai/list-models.md) 里的 `reasoning`）；不支持的档位使用时换成最接近的一档，`null` 表示使用模型的建议档位。
- `dailyLimit` 是滚动 24 小时内调用模型的提问上限（1–1000000），`null` 表示不限；未设置时默认 200。

Base URL: https://api.butterix.com/v1

Authentication: bearer token in Authorization header or API key in cookie `biti_session`

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `site` | string | yes | 站点 slug 或 id |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `enabled` | boolean | no |  |
| `provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. |
| `model` | string | no |  |
| `apiKey` | string | no | 新密钥；`null` 表示清除 May be null. |
| `guidance` | string | no | 附加到系统提示的指引 |
| `effort` | enum | no | 推理强度；`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. |
| `dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限；`null` 表示不限 May be null. |
| `agent` | boolean | no | 控制台 AI（Agent、定时任务、AI 翻译、文档缺口）的开关，与 Ask AI 互不影响 |
| `gaps` | boolean | no | 每天自动整理文档缺口 |
| `support` | object | no | 答不上时转人工。只更新传入的字段；开启时至少要有一种联系方式 |
| `support.enabled` | boolean | no |  |
| `support.url` | string | no | 支持页面：`https://` 地址或 `/` 开头的站内路径；空串表示清除 |
| `support.email` | string | no | 支持邮箱；空串表示清除 |

## Example request

```bash
curl -X PUT https://api.butterix.com/v1/sites/acme-payments/ai \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
         "provider": "deepseek",
         "model": "deepseek-flash",
         "apiKey": "sk-xxxxxxxxxxxxxxxx"
       }'
```

## Responses

### 200

更新后的设置

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `enabled` | boolean | no |  |
| `provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. |
| `model` | string | no |  |
| `hasKey` | boolean | no | 是否设置了站点密钥 |
| `keyMasked` | string | no |  |
| `platformKeyAvailable` | boolean | no | 平台是否为当前提供商配置了默认密钥 |
| `platformKeys` | map from strings to booleans | no | 每个提供商是否有平台密钥 |
| `guidance` | string | no |  |
| `effort` | enum | no | 推理强度；`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. |
| `retentionDays` | integer | no | 提问记录保留天数；`null` 表示一直保留 May be null. |
| `dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限；`null` 表示不限 May be null. |
| `agent` | boolean | no | 控制台 AI 是否启用 |
| `gaps` | boolean | no | 是否每天自动整理文档缺口 |
| `support` | object | no | 答不上时转人工 |
| `support.enabled` | boolean | no |  |
| `support.url` | string | no |  |
| `support.email` | string | no |  |

### Example response (200)

```json
{
  "enabled": true,
  "provider": "anthropic",
  "model": "claude-opus-5-5",
  "hasKey": true,
  "keyMasked": "sk-a…9f2c",
  "platformKeyAvailable": true,
  "platformKeys": {
    "key": true
  },
  "guidance": "string",
  "effort": "none",
  "retentionDays": 1,
  "dailyLimit": 200,
  "agent": true,
  "gaps": false,
  "support": {
    "enabled": false,
    "url": "",
    "email": ""
  }
}
```
