# Tavily Extract

**API:** Data API

**Endpoint:** `POST /v1/beta/tavily/extract`

**Tags:** Web Content

從一個 URL 或 URL 陣列擷取可讀內容。以 format 選擇 text 或 Markdown。請同時檢查 results 與 failed_results：失敗的 URL 可能在整體成功的 HTTP 回應中回報。設定 include_usage 以接收資源用量資訊；usage.credits 並非 Felo 費用。

### 計費參考

- 計量方式：依回應單位計量。
- 參考請求估算：0.024 美元。
- 單位成本基準：0.008 美元。
- 資源單位：`tavily_credit`。
- 參考客戶乘數：1.0。不得再次套用於已結算的客戶金額。
- 成本基礎不構成最終客戶價格，即使為零亦同。

僅供參考的中繼資料，並非帳戶報價、保證價格或消費上限。資源額度並非 Felo 額度。最終費用依 Felo 計費記錄為準。

## Base URL

- `https://openapi.felo.ai`

## Authentication

- `FeloBearerAuth` (http bearer, bearer format Felo API Key)
- `FeloApiKey` (apiKey in header `X-API-Key`)

## Request body

Required: **yes**

### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "urls": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      ],
      "description": "要擷取內容的 URL。單一 URL 字串和 URL 字串陣列皆可接受。",
      "example": [
        "https://en.wikipedia.org/wiki/Artificial_intelligence"
      ]
    },
    "query": {
      "type": "string",
      "description": "用於對擷取的內容區塊重新排序的使用者意圖。"
    },
    "chunks_per_source": {
      "type": "integer",
      "default": 3,
      "description": "每個來源傳回的相關區塊最大數。僅在提供 query 時可用。",
      "minimum": 1,
      "maximum": 5
    },
    "extract_depth": {
      "type": "string",
      "enum": [
        "basic",
        "advanced"
      ],
      "default": "basic",
      "description": "擷取過程的深度。"
    },
    "include_images": {
      "type": "boolean",
      "default": false,
      "description": "包含從 URL 擷取的圖片清單。"
    },
    "include_favicon": {
      "type": "boolean",
      "default": false,
      "description": "為每筆結果包含 favicon URL。"
    },
    "format": {
      "type": "string",
      "enum": [
        "markdown",
        "text"
      ],
      "default": "markdown",
      "description": "擷取的網頁內容格式。"
    },
    "timeout": {
      "type": "number",
      "format": "float",
      "description": "URL 擷取的最長等待時間（秒）。省略時，預設逾時取決於 extract_depth：basic 為 10 秒，advanced 為 30 秒。",
      "minimum": 1,
      "maximum": 60
    },
    "include_usage": {
      "type": "boolean",
      "default": false,
      "description": "在回應中包含資源用量資訊。此資訊不是 Felo 計費資訊。"
    }
  },
  "required": [
    "urls"
  ]
}
```

Example:

```json
{
  "urls": [
    "https://example.com"
  ],
  "extract_depth": "basic",
  "format": "text",
  "include_usage": true
}
```

## Responses

### 200 — 已成功傳回擷取結果。

Headers:
- `X-Request-Id` (string) — 聯絡 Felo 支援時需提供的請求識別碼。

**application/json**

Schema: object

```json
{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "已擷取內容的 URL。"
          },
          "title": {
            "type": "string",
            "description": "已擷取頁面的標題。"
          },
          "raw_content": {
            "type": "string",
            "description": "從 URL 擷取的原始內容。"
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "include_images 為 true 時從 URL 擷取的圖片。"
          },
          "favicon": {
            "type": [
              "string",
              "null"
            ],
            "description": "擷取內容的 Favicon URL。"
          }
        }
      }
    },
    "failed_results": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "無法處理的 URL 清單。"
    },
    "response_time": {
      "type": "number",
      "format": "float",
      "description": "完成該請求所用的時間（秒）。"
    },
    "usage": {
      "type": "object",
      "properties": {
        "credits": {
          "type": "integer",
          "description": "此請求消耗的資源單位，不是美元或 Felo 額度。"
        }
      }
    },
    "request_id": {
      "type": "string",
      "description": "唯一的請求識別碼。"
    }
  }
}
```

Example:

```json
{
  "results": [
    {
      "url": "https://example.com",
      "title": "Example Domain",
      "raw_content": "This domain is for use in documentation examples.",
      "images": []
    }
  ],
  "failed_results": [],
  "response_time": 0.5,
  "usage": {
    "credits": 1
  },
  "request_id": "example-extract-request"
}
```

### 400 — 無法處理該要求。請檢查請求參數。

### 401 — 需要有效的 Felo API 金鑰。

### 402 — 由於未符合計費要求，要求無法繼續。

### 403 — 該帳戶無權執行此操作。

### 429 — 已達到要求或支出上限。

### 502 — 服務無法完成該要求。

### 503 — API 或計費服務暫時無法使用。

### 504 — 服務在處理要求時逾時。

### default — 錯誤回應；上游透傳回應可能採用供應商格式

**application/json**

Schema:

```json
{}
```
