# Instinct

让 Instinct 使用 Felo Data API 查询到的数据。Agent 继续使用自带的模型，Felo 负责为任务提供搜索结果。

让 Instinct 使用 Felo Data API 查询到的数据。Agent 继续使用自带的模型，Felo 负责为任务提供搜索结果。

## 开始前准备

先创建 API key 并确认账户有可用额度。本文以 Tavily 搜索接口为例；其他 Data API 的参数和价格以各自文档为准。

- [API Keys](https://openapi.felo.ai/console/api-keys)
- [Data APIs](https://openapi.felo.ai/zh-CN/apis)
- [Tavily](https://openapi.felo.ai/zh-CN/apis/tavily)

## 在应用中配置

**Google Sheets → Extensions → Apps Script → Google Docs → Instinct Google Workspace connection**

## 把查询变成 Agent 工具

这里通过 Google Workspace 接入：Apps Script 调用 Felo Data API，将查询结果写入表格和 Google 文档，再由 Agent 读取。不依赖 Agent 提供自定义 API 设置。

[felo-data-sheets.gs](https://openapi.felo.ai/docs-assets/integrations/felo-data-sheets.gs)

1. 新建 Google 表格，打开“扩展程序 → Apps Script”，粘贴下载的脚本，保存后运行 setupFeloDataSheet 并授权。
2. 在 Queries!A2 填搜索词。在“项目设置 → 脚本属性”中添加 FELO_API_KEY，值为你的 key；不要把 key 写进单元格或 Agent 对话。
3. 运行 refreshFeloData。Results 表保存标题、网址、摘要；Config!B1 是生成的 Google 文档链接。再次运行会更新同一份文档。
4. 在 Agent 中连接同一个 Google 账号，确认它有权读取输出文档，粘贴文档链接，让它读取内容并附上来源网址。

```text
setupFeloDataSheet()
refreshFeloData()
```

## Data API 请求示例

| Field | Value |
| --- | --- |
| Method | `POST` |
| URL | `https://openapi.felo.ai/v1/beta/tavily/search` |
| Authorization | `Bearer YOUR_FELO_API_KEY` |
| OpenAPI credential | `X-API-Key: YOUR_FELO_API_KEY` |
| Content-Type | `application/json` |
| query | `Felo API Platform documentation` |
| max_results | `3` |
| Output | `results[].title`, `results[].url`, `results[].content` |

```json
{
  "query": "Felo API Platform documentation",
  "max_results": 3
}
```

```bash
export FELO_API_KEY='YOUR_FELO_API_KEY'
curl 'https://openapi.felo.ai/v1/beta/tavily/search' \
  -H "Authorization: Bearer $FELO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "query": "Felo API Platform documentation",
  "max_results": 3
}'
```

## 验证是否接入成功

执行一次搜索，检查响应是否有 results 数组，以及 title、url、content 字段。让 Agent 基于这些结果总结并引用返回的网址。空数组也是合法结果，不代表调用失败；再到控制台查看本次 API 用量，确认请求经过 Felo。

## 遇到问题怎么办

401：检查 key 和 Authorization；402：检查余额；400：检查 JSON 和 query；429 或 5xx：退避重试。保留 request_id 方便客服核查。Workspace 方式还需检查脚本授权和文档权限；电脑工具需确认 key 配置在实际执行环境。

## 继续阅读 Felo 文档

- [Data API](https://openapi.felo.ai/zh-CN/docs/guides/data-api.md)
- [API Reference](https://openapi.felo.ai/zh-CN/docs/data-api)
- [Authentication](https://openapi.felo.ai/zh-CN/docs/authentication.md)
- [Apps & Agents](https://openapi.felo.ai/zh-CN/apps)

## 应用官方资料

- [Instinct](https://instinct.com/privacy-policy)

- [Google Apps Script: UrlFetchApp](https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app)
- [Google Apps Script: PropertiesService](https://developers.google.com/apps-script/reference/properties/properties-service)
