# Exa 联网搜索

> 通用

提交 Exa 联网搜索请求。`model` 固定为 `exa-web-search`，其余字段为 Exa 原生入参，原样透传。

## 请求地址

`POST https://api.modelverse.cn/v1/web_search`

## 请求体

## 响应

- **200** — Exa 原生搜索结果。
- **default** — 错误响应（网关侧参数/鉴权错误或上游非 200）。

## OpenAPI 定义

```json
{
  "openapi": "3.1.0",
  "x-language": "zh-CN",
  "info": {
    "title": "Exa 联网搜索接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 **Exa Search** 联网搜索模型的接口文档。\n统一入口 `POST /v1/web_search`，通过请求体中的 `model` 字段选路（转发前被剥离）。\n其余字段为 Exa 原生参数，**原样透传、原样返回，不做归一化**。响应为非流式，一次性返回 JSON。\n计费：一次成功调用计 1 次，上游非 200 视为失败不计费。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API endpoint."
    }
  ],
  "tags": [
    {
      "name": "Web Search",
      "description": "Exa 联网搜索。"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/web_search": {
      "post": {
        "tags": [
          "Web Search"
        ],
        "operationId": "createExaWebSearch",
        "summary": "Exa 联网搜索",
        "description": "提交 Exa 联网搜索请求。`model` 固定为 `exa-web-search`，其余字段为 Exa 原生入参，原样透传。\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExaWebSearchRequest"
              },
              "examples": {
                "deepSearch": {
                  "summary": "深度搜索并返回高亮与正文",
                  "value": {
                    "model": "exa-web-search",
                    "query": "latest advances in large language models",
                    "numResults": 10,
                    "type": "deep",
                    "contents": {
                      "text": true,
                      "highlights": {
                        "numSentences": 3,
                        "highlightsPerUrl": 1
                      },
                      "subpages": 3,
                      "subpageTarget": "sources"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Exa 原生搜索结果。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExaWebSearchResponse"
                },
                "examples": {
                  "results": {
                    "summary": "搜索结果",
                    "value": {
                      "results": [
                        {
                          "title": "...",
                          "url": "https://...",
                          "publishedDate": "2026-01-01",
                          "author": "...",
                          "score": 0.87,
                          "highlights": [
                            "..."
                          ],
                          "text": "..."
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应（网关侧参数/鉴权错误或上游非 200）。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebSearchErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/WebSearchError"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "平台下发的 API Key，通过 `Authorization: Bearer <API Key>` 传入。"
      }
    },
    "schemas": {
      "ExaWebSearchRequest": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "model",
          "query"
        ],
        "properties": {
          "model": {
            "type": "string",
            "const": "exa-web-search",
            "description": "模型选路标识，固定为 `exa-web-search`，转发前被剥离。"
          },
          "query": {
            "type": "string",
            "description": "搜索词。"
          },
          "numResults": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "description": "返回结果数，当前仅支持 ≤ 10。"
          },
          "type": {
            "type": "string",
            "enum": [
              "auto",
              "instant",
              "fast",
              "deep"
            ],
            "description": "搜索类型。"
          },
          "contents": {
            "$ref": "#/components/schemas/ExaContents"
          }
        }
      },
      "ExaContents": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "text": {
            "type": "boolean",
            "description": "是否返回网页正文。"
          },
          "highlights": {
            "$ref": "#/components/schemas/ExaHighlights"
          },
          "subpages": {
            "type": "integer",
            "description": "抓取的子页面数量。"
          },
          "subpageTarget": {
            "type": "string",
            "description": "子页面抓取目标，例如 `sources`。"
          },
          "summary": {
            "type": "object",
            "additionalProperties": true,
            "description": "暂不支持。"
          }
        }
      },
      "ExaHighlights": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "numSentences": {
            "type": "integer",
            "description": "每条高亮的句子数。"
          },
          "highlightsPerUrl": {
            "type": "integer",
            "description": "每个 URL 的高亮条数。"
          },
          "query": {
            "type": "string",
            "description": "用于生成高亮的查询词（可选）。"
          }
        }
      },
      "ExaWebSearchResponse": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExaResult"
            },
            "description": "搜索结果列表。"
          }
        }
      },
      "ExaResult": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "title": {
            "type": "string",
            "description": "结果标题。"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "结果链接。"
          },
          "publishedDate": {
            "type": "string",
            "description": "发布日期。"
          },
          "author": {
            "type": "string",
            "description": "作者。"
          },
          "score": {
            "type": "number",
            "description": "相关性得分。"
          },
          "highlights": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "高亮摘录。"
          },
          "text": {
            "type": "string",
            "description": "网页正文（`contents.text=true` 时返回）。"
          }
        }
      },
      "WebSearchErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/WebSearchError"
          }
        }
      },
      "WebSearchError": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "message",
          "type",
          "code",
          "param"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "错误说明。"
          },
          "type": {
            "type": "string",
            "description": "错误类型。",
            "examples": [
              "invalid_request_error"
            ]
          },
          "code": {
            "type": "string",
            "description": "机器可读的错误码。",
            "examples": [
              "error_code"
            ]
          },
          "param": {
            "type": "string",
            "description": "请求 ID，用于反馈或排查错误原因。"
          }
        }
      }
    },
    "examples": {
      "WebSearchError": {
        "summary": "标准 JSON 错误响应",
        "value": {
          "error": {
            "message": "错误描述信息",
            "type": "invalid_request_error",
            "code": "error_code",
            "param": "<请求 ID，用于反馈或排查错误原因>"
          }
        }
      }
    }
  }
}
```
