跳转到内容
EN

提取网页内容

POST/tavily/extract● 支持

Tavily 官方文档 ↗

请求体

  • querystring可选

    User intent for reranking extracted content chunks. When provided, chunks are reranked based on relevance to this query.

  • urlsstring | array必填
  • chunks_per_sourceinteger可选
    默认 3

    Chunks are short content snippets (maximum 500 characters each) pulled directly from the source. Use chunks_per_source to define the maximum number of relevant chunks returned per source and to control the raw_content length. Chunks will appear in the raw_content field as: <chunk 1> [...] <chunk 2> [...] <chunk 3>. Available only when query is provided. Must be between 1 and 5.

  • extract_depthstring可选
    默认 "basic"

    The depth of the extraction process. advanced extraction retrieves more data, including tables and embedded content, with higher success but may increase latency.basic extraction costs 1 credit per 5 successful URL extractions, while advanced extraction costs 2 credits per 5 successful URL extractions.

    取值 basicadvanced
  • include_imagesboolean可选
    默认 false

    Include a list of images extracted from the URLs in the response. Default is false.

  • include_faviconboolean可选
    默认 false

    Whether to include the favicon URL for each result.

  • formatstring可选
    默认 "markdown"

    The format of the extracted web page content. markdown returns content in markdown format. text returns plain text and may increase latency.

    取值 markdowntext
  • timeoutnumber可选
    默认 "None"

    Maximum time in seconds to wait for the URL extraction before timing out. Must be between 1.0 and 60.0 seconds. If not specified, default timeouts are applied based on extract_depth: 10 seconds for basic extraction and 30 seconds for advanced extraction.

  • include_usageboolean可选
    默认 false

    Whether to include credit usage information in the response. NOTE:The value may be 0 if the total successful URL extractions has not yet reached 5 calls. See our Credits & Pricing documentation for details.

返回

200

错误按 Tavily 格式返回,参见 错误码

请求示例

curl
curl https://api.deepraxis.com/tavily/extract \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"urls":["https://en.wikipedia.org/wiki/Artificial_intelligence"]}'
Python
from tavily import TavilyClient

tavily_client = TavilyClient(
    api_key="$PRAXIS_API_KEY",
    api_base_url="https://api.deepraxis.com/tavily",
)

response = tavily_client.extract("https://en.wikipedia.org/wiki/Artificial_intelligence")
print(response)
TypeScript
import { tavily } from "@tavily/core";

const tvly = tavily({
  apiKey: "$PRAXIS_API_KEY",
  apiBaseURL: "https://api.deepraxis.com/tavily",
});

const response = await tvly.extract("https://en.wikipedia.org/wiki/Artificial_intelligence");
console.log(response);

响应示例 200

{
  "results": [
    {
      "url": "https://en.wikipedia.org/wiki/Artificial_intelligence",
      "title": "Artificial intelligence - Wikipedia",
      "raw_content": " Artificial intelligence - Wikipedia                      \n[Jump to content](#bodyContent)\n\nMain menu \n\nMain menu\n\nmove to sidebar hide\n\nNavigation\n\n* [Main page](/wiki/Main_Page \"Visit the main page …(采样时截断:原文共 626370 字符,此处保留前 200)",
      "images": []
    }
  ],
  "failed_results": [],
  "response_time": 0.01,
  "usage": {
    "credits": 0
  },
  "request_id": "ab92449c-3270-4c00-bcd3-53d4e267ac00"
}

响应

HTTP 200

Extraction completed. Check results and failed_results for each URL. HTTP 200 can have an empty results array when all valid URLs fail during extraction; output order is not guaranteed.

application/json

名称 类型 说明
results array<object> A list of extracted content from the provided URLs.
results[].url string The URL from which the content was extracted.
results[].raw_content string The full content extracted from the page. When query is provided, contains the top-ranked chunks joined by [...] separator.
results[].images array<string> This is only available if include_images is set to true. A list of image URLs extracted from the page.
results[].favicon string The favicon URL for the result.
failed_results array<object> A list of URLs that could not be processed.
failed_results[].url string The URL that failed to be processed.
failed_results[].error string An error message describing why the URL couldn't be processed.
response_time number Time in seconds it took to complete the request.
usage object Credit usage details for the request.
request_id string A unique request identifier you can share with customer support to help resolve issues with specific requests.