# 基于模型的网络搜索（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 对象，包含 tool-use、search-result 和 text 块。usage 报告资源消耗，而非 Felo 扣费。

### 计费参考

- 计量方式：按响应组件计量。
- 参考请求估算：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
{}
```
