# モデルに基づくウェブ検索（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": "回答で生成するトークンの最大数。上流の 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
{}
```
