# 以模型為依據的網路搜尋（Anthropic）。

**API:** Data API

**Endpoint:** `POST /v1/beta/anthropic-websearch/search`

**Tags:** Anthropic Web Search

使用 Claude 與網路搜尋產生附引用來源的答案。提供 messages 與 max_tokens。模型與 web_search 工具由服務管理；max_uses 限制搜尋次數。回應是 Anthropic Messages 物件，包含工具使用、搜尋結果與文字區塊。usage 回報資源用量，並非 Felo 收費。

### 定價參考

- 計量方式：依回應元件計量。
- 參考請求預估：USD 0.3。
- 參考客戶乘數：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",
  "required": [
    "messages",
    "max_tokens"
  ],
  "properties": {
    "messages": {
      "type": "array",
      "description": "對話訊息，格式與 Anthropic Messages API 相同。使用者回合中承載你的問題。",
      "items": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant"
            ]
          },
          "content": {
            "type": "string",
            "description": "訊息文字。也接受結構化內容區塊。"
          }
        }
      },
      "example": [
        {
          "role": "user",
          "content": "What are the three biggest AI announcements this week? Give one sentence each with sources."
        }
      ]
    },
    "max_tokens": {
      "type": "integer",
      "description": "回答中可產生的最大 token 數。上游 Messages API 要求必填。",
      "default": 1024,
      "example": 1024
    },
    "system": {
      "type": "string",
      "description": "選用的系統提示詞，用於控制回答的語氣或格式。"
    }
  }
}
```

Example:

```json
{
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "What are the three biggest AI announcements this week? Give one sentence each with sources."
    }
  ]
}
```

## Responses

### 200 — 標準的 Anthropic Messages 回應。`content[]` 交錯包含執行的搜尋與附引用的答案；`usage.server_tool_use.web_search_requests` 是計費的搜尋次數。

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

**application/json**

Schema: object

```json
{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "type": {
      "type": "string",
      "example": "message"
    },
    "role": {
      "type": "string",
      "example": "assistant"
    },
    "stop_reason": {
      "type": "string",
      "example": "end_turn"
    },
    "content": {
      "type": "array",
      "description": "依序排列的區塊：server_tool_use（搜尋查詢）、web_search_tool_result（來源）與 text（附引用的回答）。",
      "items": {
        "type": "object"
      }
    },
    "usage": {
      "type": "object",
      "properties": {
        "input_tokens": {
          "type": "integer"
        },
        "output_tokens": {
          "type": "integer"
        },
        "cache_read_input_tokens": {
          "type": "integer"
        },
        "cache_creation_input_tokens": {
          "type": "integer"
        },
        "server_tool_use": {
          "type": "object",
          "properties": {
            "web_search_requests": {
              "type": "integer",
              "description": "計費的網路搜尋次數。"
            }
          }
        }
      }
    }
  }
}
```

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

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

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

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

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

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

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

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

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

**application/json**

Schema:

```json
{}
```
