# 请求超时问题

由于 **openkey.cloud** 主站接入了 **Cloudflare CDN**，在网络边缘层会存在一个**强制请求超时上限**（通常在 **100–120 秒** 左右）。这意味着：当上游模型需要较长时间“思考/生成”时，请求可能会在到达上限时被 Cloudflare **直接中断**，即使模型端仍在处理，也可能出现 **报错但已扣费** 的情况（尤其是带推理/思考的模型，如 GPT-5、Gemini 2.5 等）。

为满足长耗时任务，我们提供了一个不经过 Cloudflare 的备用入口 **openkey.red**，用于尽可能避免 100–120 秒的边缘超时限制。

***

### 两个接入点的区别

#### 1) 主站点：`https://openkey.cloud/`

**特点**

* ✅ 高可用、自动故障迁移
* ✅ 更适合常规请求、稳定性优先的场景
* ⚠️ 受 Cloudflare 影响，存在 **100–120 秒强制超时中断**（请求可能被提前终止）

**适用场景**

* 大多数普通对话、短输出、低延迟调用
* 对可用性要求高、能接受“单次请求不要太久”的业务

***

#### 2) 备用站点（裸节点）：`https://openkey.red/`

**特点**

* ✅ 不走 Cloudflare CDN，**无 100–120 秒强制超时限制**
* ✅ 理论最大超时可到 **600 秒**（取决于你的客户端/网关/上游配置）
* ⚠️ 无高可用与自动迁移，若节点异常需要人工介入修复

**适用场景**

* 长文本生成、复杂推理、慢模型
* 单次请求可能超过 100 秒的任务（例如长链路 Agent、长报告、超长上下文等）

***

### 常见现象与报错

当你看到类似以下错误时，通常意味着请求在边缘层超时被中断：

* `524: A timeout occurred`
* `cf-error`
* 请求在 \~100–120 秒附近结束，但上游仍可能已处理/计费

如果你的业务确实需要更长处理时间，建议将该类请求切换到 **openkey.red**。

***

### 如何切换到 openkey.red

你只需要把“Base URL / Endpoint”从 `openkey.cloud` 换成 `openkey.red`：

* `https://openkey.cloud/` → `https://openkey.red/`

例如（OpenAI 兼容接口风格）：

```bash
curl https://openkey.red/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{
    "model": "gpt-5",
    "messages": [{"role":"user","content":"..."}]
  }'
```

> 你的客户端/SDK 也请同时检查自身的超时设置（例如 HTTP client timeout），避免客户端先于服务端超时。

***

### 用日志“耗时”栏目辅助判断是否需要切换

我们已在 OpenKey 的日志页面新增了 **“耗时”** 栏目（单位：秒）。你可以用它来快速判断：

* 如果耗时经常接近或超过 **100–120s**：建议将该类请求迁移到 `openkey.red`
* 如果耗时通常在几十秒内：继续使用 `openkey.cloud` 更合适（高可用 + 自动迁移）

***

### 建议的迁移策略

* **默认走 `openkey.cloud`**（高可用优先）
* 对“长耗时请求”做**分流**：
  * 例如：带思考/推理模型、长报告生成、长上下文任务 → `openkey.red`
  * 其余常规请求 → `openkey.cloud`

***

### 需要帮助？

如果你在切换或使用过程中遇到任何问题（例如仍超时、日志显示异常耗时、扣费与返回不一致等），请把**请求时间点**与**日志记录**发给我们，我们会协助定位与优化。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.openkey.cloud/help/timeout.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
