# 豆包搜索 Custom 版

> 通用

提交豆包搜索 Custom 版请求。`model` 固定为 `doubao-web-search-custom`，其余字段为豆包原生入参（大驼峰），原样透传。

## 请求地址

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

## 请求体

## 响应

- **200** — 豆包 Custom 原生响应。HTTP 200 且 `ResponseMetadata.Error.Code` 为空才算成功。
- **default** — 错误响应（网关侧参数/鉴权错误或上游非 200）。

## OpenAPI 定义

```json
{
  "openapi": "3.1.0",
  "x-language": "zh-CN",
  "info": {
    "title": "豆包搜索 Custom 版接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 **豆包搜索 Custom 版** 联网搜索模型的接口文档。\n统一入口 `POST /v1/web_search`，通过请求体中的 `model` 字段选路（转发前被剥离）。\n其余字段为豆包搜索原生参数（大驼峰命名），**原样透传、原样返回，不做归一化**。响应为非流式。\n计费：一次成功调用计 1 次；HTTP 200 但 `ResponseMetadata.Error.Code` 非空视为业务失败，不计费。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API endpoint."
    }
  ],
  "tags": [
    {
      "name": "Web Search",
      "description": "豆包搜索 Custom 版联网搜索。"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/web_search": {
      "post": {
        "tags": [
          "Web Search"
        ],
        "operationId": "createDoubaoWebSearchCustom",
        "summary": "豆包搜索 Custom 版",
        "description": "提交豆包搜索 Custom 版请求。`model` 固定为 `doubao-web-search-custom`，其余字段为豆包原生入参（大驼峰），原样透传。\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DoubaoCustomRequest"
              },
              "examples": {
                "webSearch": {
                  "summary": "网页搜索并启用 Query 改写",
                  "value": {
                    "model": "doubao-web-search-custom",
                    "Query": "最新的北京游玩攻略",
                    "SearchType": "web",
                    "Count": 10,
                    "Filter": {
                      "NeedContent": false,
                      "NeedUrl": true,
                      "TimeRange": "OneYear"
                    },
                    "QueryControl": {
                      "QueryRewrite": true
                    },
                    "ContentFormats": "markdown"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "豆包 Custom 原生响应。HTTP 200 且 `ResponseMetadata.Error.Code` 为空才算成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DoubaoCustomResponse"
                },
                "examples": {
                  "success": {
                    "summary": "成功响应（节选）",
                    "value": {
                      "ResponseMetadata": {
                        "RequestId": "...",
                        "Error": {
                          "Code": "",
                          "Message": ""
                        }
                      },
                      "Result": {
                        "ResultCount": 10,
                        "WebResults": [
                          {
                            "Title": "...",
                            "Url": "https://...",
                            "Snippet": "...",
                            "Content": "...",
                            "Position": 1
                          }
                        ],
                        "ImageResults": [],
                        "SearchContext": {
                          "OriginQuery": "最新的北京游玩攻略",
                          "SearchType": "web"
                        },
                        "TimeCost": 123,
                        "LogId": "..."
                      }
                    }
                  }
                }
              }
            }
          },
          "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": {
      "DoubaoCustomRequest": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "model",
          "Query",
          "SearchType"
        ],
        "properties": {
          "model": {
            "type": "string",
            "const": "doubao-web-search-custom",
            "description": "模型选路标识，固定为 `doubao-web-search-custom`，转发前被剥离。"
          },
          "Query": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "搜索词，1–100 字符。"
          },
          "SearchType": {
            "type": "string",
            "enum": [
              "web",
              "image"
            ],
            "description": "搜索类型。"
          },
          "Count": {
            "type": "integer",
            "description": "返回结果数，web ≤ 50 / image ≤ 5，默认 10。"
          },
          "Filter": {
            "$ref": "#/components/schemas/DoubaoCustomFilter"
          },
          "QueryControl": {
            "$ref": "#/components/schemas/DoubaoCustomQueryControl"
          },
          "ContentFormats": {
            "type": "string",
            "enum": [
              "text",
              "markdown"
            ],
            "description": "正文返回格式。"
          },
          "Industry": {
            "type": "string",
            "enum": [
              "finance",
              "game",
              "health",
              "gov"
            ],
            "description": "行业垂直搜索。"
          }
        }
      },
      "DoubaoCustomFilter": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "NeedContent": {
            "type": "boolean",
            "description": "是否返回网页正文。"
          },
          "NeedUrl": {
            "type": "boolean",
            "description": "是否返回结果 URL。"
          },
          "Sites": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "站点白名单。"
          },
          "BlockHosts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "站点黑名单。"
          },
          "TimeRange": {
            "type": "string",
            "description": "时间范围：`OneDay` / `OneWeek` / `OneMonth` / `OneYear`，或日期区间。"
          }
        }
      },
      "DoubaoCustomQueryControl": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "QueryRewrite": {
            "type": "boolean",
            "description": "是否启用 LLM 对 Query 进行改写以提升召回。"
          }
        }
      },
      "DoubaoCustomResponse": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "ResponseMetadata": {
            "$ref": "#/components/schemas/DoubaoResponseMetadata"
          },
          "Result": {
            "$ref": "#/components/schemas/DoubaoCustomResult"
          }
        }
      },
      "DoubaoResponseMetadata": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "RequestId": {
            "type": "string",
            "description": "请求唯一标识。"
          },
          "Error": {
            "$ref": "#/components/schemas/DoubaoError"
          }
        }
      },
      "DoubaoError": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "Code": {
            "type": "string",
            "description": "业务错误码，成功时为空字符串。"
          },
          "Message": {
            "type": "string",
            "description": "业务错误描述，成功时为空字符串。"
          }
        }
      },
      "DoubaoCustomResult": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "ResultCount": {
            "type": "integer",
            "description": "返回结果数。"
          },
          "WebResults": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DoubaoWebItem"
            },
            "description": "网页结果列表（SearchType=web 时返回）。"
          },
          "ImageResults": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "图片结果列表（SearchType=image 时返回）。"
          },
          "SearchContext": {
            "type": "object",
            "additionalProperties": true,
            "description": "搜索上下文，含 OriginQuery、SearchType。"
          },
          "TimeCost": {
            "type": "integer",
            "description": "上游耗时（毫秒）。"
          },
          "LogId": {
            "type": "string",
            "description": "上游日志 ID。"
          }
        }
      },
      "DoubaoWebItem": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "Title": {
            "type": "string",
            "description": "网页标题。"
          },
          "Url": {
            "type": "string",
            "format": "uri",
            "description": "网页地址。"
          },
          "Snippet": {
            "type": "string",
            "description": "摘要片段。"
          },
          "Content": {
            "type": "string",
            "description": "网页正文（Filter.NeedContent=true 时返回）。"
          },
          "Position": {
            "type": "integer",
            "description": "结果排序位置。"
          }
        }
      },
      "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，用于反馈或排查错误原因>"
          }
        }
      }
    }
  }
}
```
