---
title: "Latency"
description: "了解响应 latency 的构成,以及与直接调用基础模型相比的差异。"
---

# Latency

了解 Minds API 的响应时间与直接调用基础模型相比的差异,以及造成差异的原因。

## 概览

当你通过 Minds API 发送消息时,返回的响应不仅仅是一次原始的 LLM 调用。API 会编排多个步骤,将响应基于你的 mind 的知识库进行 grounding,从而提供更高质量、更具上下文的回答。

**典型响应时间:**

<table>
<thead>
  <tr>
    <th>
      场景
    </th>
    
    <th>
      Latency
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      直接调用基础模型(无上下文)
    </td>
    
    <td>
      1-3s
    </td>
  </tr>
  
  <tr>
    <td>
      Minds API(带知识 grounding)
    </td>
    
    <td>
      5-12s
    </td>
  </tr>
  
  <tr>
    <td>
      Minds API(简单问候/无 RAG)
    </td>
    
    <td>
      2-4s
    </td>
  </tr>
</tbody>
</table>

额外的时间用于知识检索与 grounding,这正是 Minds 响应比原始 LLM 调用更准确、更具上下文的原因。

## 一次请求中发生了什么

当你调用 `POST /api/v1/minds/{mindId}/completion` 时,API 会执行以下步骤:

```text
1. Authentication & mind loading          ~50ms
2. Knowledge retrieval (RAG)              ~1-3s
   - Semantic search across embeddings
   - Retrieve relevant knowledge chunks
3. Tool orchestration                     ~1-3s
   - Web search (if needed)
   - Knowledge grounding & citations
4. LLM generation                         ~1-3s
   - Same latency as calling the model directly
5. Response formatting & citations         ~50ms
```

**第 2-3 步正是 Minds 与原始 API 调用的区别所在。** 它们为你的 mind 提供了来自知识库的相关上下文、web 搜索结果,以及有依据的引用。

## 基准测试结果

测量日期为 2026 年 3 月 12 日。每项测试使用相同 prompt 运行 3 次。Minds API 调用包含完整的 RAG 流水线和工具编排。

### 不同模型的响应时间

<table>
<thead>
  <tr>
    <th>
      Endpoint
    </th>
    
    <th>
      平均值
    </th>
    
    <th>
      最小值
    </th>
    
    <th>
      最大值
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Minds API (默认)
      </strong>
    </td>
    
    <td>
      12,166ms
    </td>
    
    <td>
      10,951ms
    </td>
    
    <td>
      13,910ms
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Minds API (gpt-4o)
      </strong>
    </td>
    
    <td>
      7,013ms
    </td>
    
    <td>
      5,900ms
    </td>
    
    <td>
      8,203ms
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Minds API (gpt-4o-mini)
      </strong>
    </td>
    
    <td>
      6,651ms
    </td>
    
    <td>
      4,702ms
    </td>
    
    <td>
      7,975ms
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Minds API (gemini-2.5-flash)
      </strong>
    </td>
    
    <td>
      7,553ms
    </td>
    
    <td>
      5,170ms
    </td>
    
    <td>
      11,198ms
    </td>
  </tr>
  
  <tr>
    <td>
      Direct OpenAI (gpt-4o)
    </td>
    
    <td>
      1,461ms
    </td>
    
    <td>
      1,139ms
    </td>
    
    <td>
      1,720ms
    </td>
  </tr>
  
  <tr>
    <td>
      Direct OpenAI (gpt-4o-mini)
    </td>
    
    <td>
      1,784ms
    </td>
    
    <td>
      1,589ms
    </td>
    
    <td>
      1,925ms
    </td>
  </tr>
  
  <tr>
    <td>
      Direct Google (gemini-2.5-flash)
    </td>
    
    <td>
      1,593ms
    </td>
    
    <td>
      1,466ms
    </td>
    
    <td>
      1,701ms
    </td>
  </tr>
</tbody>
</table>

### 额外开销分解

<table>
<thead>
  <tr>
    <th>
      模型
    </th>
    
    <th>
      Minds API
    </th>
    
    <th>
      直接调用
    </th>
    
    <th>
      额外开销
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      gpt-4o-mini
    </td>
    
    <td>
      6,651ms
    </td>
    
    <td>
      1,784ms
    </td>
    
    <td>
      +4,867ms
    </td>
  </tr>
  
  <tr>
    <td>
      gpt-4o
    </td>
    
    <td>
      7,013ms
    </td>
    
    <td>
      1,461ms
    </td>
    
    <td>
      +5,551ms
    </td>
  </tr>
  
  <tr>
    <td>
      gemini-2.5-flash
    </td>
    
    <td>
      7,553ms
    </td>
    
    <td>
      1,593ms
    </td>
    
    <td>
      +5,960ms
    </td>
  </tr>
</tbody>
</table>

**平均额外开销:在所测试的所有模型中约为 5.5 秒。** 这些开销涵盖:

- 在 mind 的向量 embedding 上执行 semantic search
- 知识片段检索与排序
- Web 搜索校验(在适用时)
- 引用映射与响应 grounding
- 工具编排流水线

## 额外开销换来的价值

这段额外的 latency 是智能的成本。原始 LLM 调用对你的领域毫无上下文。Minds 提供:

1. **知识 grounding**:响应基于你的 mind 特定的知识库,而非仅模型的训练数据
2. **自动引用**:清楚知道哪些来源构成了该响应
3. **Web 搜索校验**:将知识与实时 web 数据交叉验证
4. **Persona 一致性**:响应保持 mind 的人格与沟通风格
5. **思维模式**:塑造 mind 推理方式的心理学建模

## 优化 Latency

### 选择合适的模型

使用 `model` 参数在合适场景下选择更快的模型:

```bash
# Fastest: lightweight models
curl -X POST "https://api.getminds.ai/v1/minds/{mindId}/completion" \
  -H "Authorization: Bearer minds_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [{"role": "user", "content": "Quick question"}],
    "model": "gpt-4o-mini"
  }'
```

**模型速度排名**(从最快到最慢):

1. `gpt-4o-mini` / `gemini-3.7-flash` — 最适合对速度敏感的场景
2. `gpt-4o` / `claude-sonnet-4-5` — 速度与质量兼顾
3. 默认(服务器选择) — 针对质量优化

### 保持消息简洁

更短的对话历史可减少处理时间。`messages` 数组中只包含相关上下文。

### 预热 Mind

mind 在一段时间未使用后,第一次请求可能因冷启动略慢。后续请求将从缓存的 embedding 和预热的连接中受益。

## Streaming(即将推出)

我们正在为 completion endpoint 开发 streaming 支持,可在完整响应生成的同时更快交付首个 tokens。这将显著提升交互式应用的感知 latency。

## Rate Limit

v1 API 按已认证账户执行可配置的固定时间窗限流（默认每分钟 300 个请求）。请读取 `RateLimit-*` 标头，在 `429` 后遵循 `Retry-After`，并限制并发。详情见[错误与限制](/docs/api/errors)。

## 下一步

- [Chat API](/docs/api/chat) - 发送消息并获取响应
- [Knowledge API](/docs/api/knowledge) - 管理你的 Mind 知识库
- [API 概览](/docs/api/overview) - 完整 endpoint 参考
