# Claude Duet

Dùng kết quả Felo Data API trong Claude Duet. Agent vẫn giữ mô hình riêng.

Dùng kết quả Felo Data API trong Claude Duet. Agent vẫn giữ mô hình riêng.

## Chuẩn bị

Tạo API key và kiểm tra số dư. Ví dụ dùng Tavily Search; API khác có tham số và giá riêng.

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

## Cấu hình ứng dụng

**Google Sheets → Extensions → Apps Script → Google Docs → Claude Google Drive connector → Duet**

## Kết nối tìm kiếm

Qua Google Workspace: Apps Script gọi Felo Data API và ghi kết quả vào trang tính cùng tài liệu Google để agent đọc.

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

1. Trong Google Sheets, mở Extensions → Apps Script, lưu mã đã tải, chạy setupFeloDataSheet và cấp quyền.
2. Điền Queries!A2. Lưu FELO_API_KEY tại Project Settings → Script Properties, không ghi vào ô hoặc chat.
3. Chạy refreshFeloData. Results chứa dữ liệu, Config!B1 chứa liên kết tài liệu. Chạy lại sẽ cập nhật cùng tài liệu.
4. Kết nối cùng tài khoản Google với agent, cấp quyền đọc rồi gửi liên kết để tóm tắt kèm nguồn.

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

## Yêu cầu 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
}'
```

## Kiểm tra

Kiểm tra title, url, content trong results; yêu cầu tóm tắt có URL nguồn và xem mức sử dụng Felo trên console. Mảng rỗng vẫn hợp lệ.

## Khắc phục lỗi

401: key và Authorization; 402: số dư; 400: JSON và query. Thử lại 429/5xx với thời gian chờ tăng dần. Giữ request_id. Kiểm tra quyền Workspace hoặc key trong môi trường chạy.

## Tài liệu Felo liên quan

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

## Tài liệu chính thức của ứng dụng

- [Claude Duet](https://support.claude.com/en/articles/17631495-get-started-with-claude-duet)

- [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)
