# 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
{}
```
