Direct DeepSeek Search and Fetch APIs
直接接入 DeepSeek Search 与 Fetch API
DeepSeek web retrieval through Messages requires an auxiliary model request for each query. Harness extracts sources and citation excerpts but discards the generated answer. The dedicated Search and Fetch APIs provide structured sources and Markdown directly, so retrieval can run without Harness starting that auxiliary generation. Adopting these APIs requires explicit selection of both operations, independent deploym
English
Problem
DeepSeek web retrieval through Messages requires an auxiliary model request for each query. Harness extracts sources and citation excerpts but discards the generated answer. The dedicated Search and Fetch APIs provide structured sources and Markdown directly, so retrieval can run without Harness starting that auxiliary generation. Adopting these APIs requires explicit selection of both operations, independent deployment addresses, and a mapping of Fetch results onto the existing fetch result.
Decision
The DeepSeek Search and Fetch guide, checked on 2026-10-16, defines the upstream API. The web-deepseek-api plugin implements it behind the existing web_search and web_fetch tools. The web capability decision continues to own provider selection, tool responsibilities, and the fetch result fields, and the web provider selection decision owns how users choose each provider and which providers the shipped composition selects.
Protocol selection and deployment
The APIs register as deepseek-search-api and deepseek-fetch-api. Messages search remains separately registered as deepseek-official. The web service selects each provider through web.searchProvider and web.fetchProvider, which the Search and Fetch menus on the Web search and fetch page set independently; the shipped composition selects local HTTP fetch and no search provider, which runs the Search API outside the DeepSeek model routes, as the selection decision records. A saved selection takes effect on the next operation because the web service reads both selections per operation. Each operation resolves one settings snapshot, including its endpoint and credential. Both APIs read the web-deepseek-api namespace, and each capability resolves its own endpoint and credential.
Direct retrieval appends /search or /fetch to an API base. A capability without its own YAML endpoint fields uses the origin of the conversation's DeepSeek model route base URL with /v1/tools, which for the public deployment is the guide's https://api.deepseek.com/v1/tools; the selection decision owns that derivation and the credential each operation sends. The verified development base is http://api-dev.deepseek.com:8031/api/v1/tools; its prefix differs and is never inferred from the hostname, so such a deployment sets the complete base in searchBaseURL or fetchBaseURL. An unparseable base leaves that capability's provider unavailable.
The guide specifies API-key Bearer authentication, and requests send only the documented authorization and JSON content type. A conversation on the deepseek-account route sends the account token instead; the public Search and Fetch routes accepted it on 2026-10-16, so account-only users have direct retrieval. An Anthropic-compatible gateway checked the same day served Messages web search and had no /v1/tools routes; such deployments can select Messages search or set the capability's own base URL to one that serves /v1/tools.
Search results and model input
Direct Search sends query, count, need_content: false, and ori_question. count is the configured value from 1 to 50, defaulting to the service's 10, unless the request's result bound is smaller; the tool always sends its limit, 8 by default. ori_question is the text of the initiating Session's latest human prompt with whitespace collapsed and cut to the API's 128-character limit. The API rejects blank or longer values, so a search without such a prompt omits the field, and sendOriginalQuestion: false disables it. In 2026-10-16 probes, different values left result order, scores, and summaries unchanged. Queries pass through unchanged, including the documented site, language, date, exclusion, and exact-phrase operators. The service enforces the 1–128 Unicode-character query constraint. Empty results is successful.
The provider preserves service order and maps URL, title, snippet, summary, and nullable date into shared sources. Following the guide, the tool gives the model each source's summary and keeps the short snippet for the search card and its replay metadata. The guide's typical summary length is not a maximum: returned summaries measured 1,000–2,300 characters on 2026-10-16. dsh-tool-web therefore collapses summary whitespace and caps each summary at searchSummaryMaxChars, 800 characters by default, the upper end of the guide's typical range; one call's summaries stay within the source cap times that cap. The summary rides in the tool output value and rendered text, which the Session already records. The provider does not consume full content, site_name, site_icon, rerank_score, or authority, and it does not send localization. Those omissions are integration limits, not absent API capabilities.
Direct retrieval emits no auxiliary model-request event because Harness makes no such request. The normal tool-call and tool-result events retain the query and model-visible result. This says nothing about the search service's internal use of models. Returned text remains external, untrusted data.
Fetch metadata and ownership
Fetch sends a URL and returns Markdown without an extra Harness summarization request. The API supplies neither a final redirected URL nor a target HTTP status, and the shared result has no title field. The provider keeps the requested URL, returns the Markdown body, and reports HTTP 200 for a successful response: the Fetch API answers 404 when the URL is unavailable, blocked by site policy, or returns an error, or when no Markdown can be extracted. On 2026-10-16 an unresolvable host returned HTTP 500 instead, so every non-success status is a retrieval failure rather than a specific target diagnosis. The shared fetch result and its consumers stay unchanged.
The HTTP provider retains its own URL validation and resource limits. Selecting DeepSeek delegates page retrieval and target access policy to that service; Harness rejects redirects of the API request and retains cancellation and bounded tool output. The reported HTTP 200 therefore means the service retrieved the page, not that Harness observed the target response. The guide's Fetch 403 means crawler-policy rejection, while 404 means no usable page content.
Default migration
The shipped composition fixes no search provider: a search runs Messages search for a model request on a DeepSeek model route and deepseek-search-api on every other route; the selection decision owns that default and its no-fallback rule. API keys and account tokens both reach the public routes. Deployments behind a gateway without /v1/tools routes set searchBaseURL to a base that serves them. A stored web.searchProvider: deepseek-official selects Messages search, and any other stored selection keeps its provider.
Legacy Messages search
The independent dsh-web-search-deepseek provider sends Messages search requests when deepseek-official is selected, as the selection decision records. Its web/deepseek-search-llm-request Session event type, including the optional thinking: { type: 'disabled' } body field that the persistence acknowledgement covers, stays declared and written in dsh-web-search-deepseek, so released Sessions that contain the event still open. Messages search sends that field because Harness discards the generated answer and the auxiliary request needs no reasoning.
Alternatives considered
Keep Messages as the only search implementation. It preserves auxiliary generation and response extraction even when callers need only sources. Direct Search removes that Harness model request.
Reuse the Messages address or infer a route prefix. The protocols and deployed prefixes differ. Separate bases preserve existing configurations and avoid sending a valid request to the wrong route.
Require an explicit Search API base. The Search API is the shipped search default outside the DeepSeek model routes, and an empty default would leave it unavailable until every user enters an address that the DeepSeek model route already determines. Other deployments still set their own base.
Keep the APIs inside the Messages provider behind a provider-local switch. A switch inside the Messages provider cannot change fetch routing, so web_fetch would stay on HTTP unless the user also edited web.fetchProvider; it also ties the APIs' lifecycle to Messages search. Separate registrations let the web service's existing selection choose each provider, without coupling either API to the Messages provider.
Share one transport between Messages search and the new APIs. A shared web transport would couple different request formats and failure mappings. Credentials instead come from one service, ctx.deepseekAuth, which releases the request headers of the API key or the account sign-in; Messages search and the Search/Fetch API transports remain independent.
Split Search and Fetch into separate packages. The guide serves both APIs from one base with one credential; separate packages would duplicate settings that address one deployment. Independent selection does not require separate packages, because each API registers its own provider id. Each operation lives in its own module, so either API can change without the other.
List every registered provider in a settings dropdown. A generic provider form derives editors from Config schemas and needs host-side display metadata on the provider interfaces. This rejection stands for the generic form: the page edits only the DeepSeek providers' settings, and other providers keep their own settings pages. The selection decision supersedes it for the provider menus, which list every registered provider by its title.
Let the model supply ori_question as a tool argument. The API defines the field as the user's original question, which the latest human prompt already records. A tool argument would change the model-facing schema shared by every search provider and invite paraphrase.
Add an extraction tool or widen the fetch result. The API retrieves one concrete web page as Markdown, which fits the existing fetch operation. Its success already implies a retrieved page, and the Markdown body carries the page heading, so widening the result would change every fetch consumer for little model-visible gain.
Consequences
Direct retrieval requires no auxiliary model tokens, but its results still consume the main model's context. One Messages web search through a gateway on 2026-10-16 consumed 8,154 input and 828 output tokens for a single server-side search. The guide prices Search and Fetch independently at CNY 5 per 1,000 successful requests with results; result count does not change a request's price. Multiple queries remain multiple requests. The stated Claude Code and Codex promotion does not establish a Harness exemption. Search API mode also sends up to 128 characters of the user's prompt to the search service with each query unless sendOriginalQuestion is off.
Search and Fetch each have an account-wide 5 QPS limit, independent of model concurrency and shared across that account's API keys. Fetch also has a target-domain limit. The tool accepts up to searchMaxQueries queries per call, 10 by default, and fails the batch if one query fails. The Search provider sends at most searchRequestsPerSecond requests, 5 by default, in any one-second window of one plugin instance, so the second five queries of a full batch start one second after the first. The pacing is not shared across processes, and the provider has no automatic retries or fallback; other processes or clients can exhaust the same account allowance.
Verification and remaining API adoption
Provider tests cover request mapping, empty results, malformed responses, independent and derived bases, account-token authentication and its invalidation after HTTP 401, cancellation, and blank configuration. Settings tests and the plugin configuration browser scenario cover staged saves, the result count, and independent Search and Fetch selection. The web search replay and Fetch Session replay pin model-visible results. On 2026-10-16 the real provider tests passed Search and Fetch against the public base, and a headless round on the shipped profile returned eight sources and fetched Markdown without an auxiliary request event. The account-token, gateway, and status observations above come from manual probes the same day.
The following capabilities remain outside the implemented integration:
- Expose search syntax in provider-appropriate tool guidance and define a bounded localization input before forwarding it. API
localizationis an IP address, not an inferred city or UI language. - Retain quality metadata before defining selection policies.
rerank_scoreandauthoritydescribe service assessments, not guarantees of truth; a hard cutoff can discard useful niche sources. - Add cancellation-aware scheduling and bounded retry ownership. The guide recommends waiting before retrying 408, 429, and 5xx; 402 requires funding first, and other 4xx require a changed request. Local pacing cannot enforce an account-wide quota across unrelated processes.
中文
问题
通过 Messages 获取 DeepSeek 网页搜索结果时,每个查询都需要一次辅助模型请求。Harness 提取来源与引用摘录,却丢弃生成的回答。独立 Search 和 Fetch API 直接提供结构化来源与 Markdown,使检索无需由 Harness 发起这次辅助生成。接入这些 API 需要明确选择两种操作的提供方、独立配置部署地址,并把 Fetch 结果映射到现有抓取结果。
决策
2026-10-16 核对的 DeepSeek Search 与 Fetch 指南定义上游 API。web-deepseek-api 插件通过现有 web_search 和 web_fetch 工具接入它。Web 能力决策继续负责提供方选择、工具职责和抓取结果字段;Web 提供方选择决策负责用户如何选择各个提供方,以及内置组合选择哪些提供方。
协议选择与部署
两个 API 注册为 deepseek-search-api 和 deepseek-fetch-api;Messages 搜索仍独立注册为 deepseek-official。Web 服务通过 web.searchProvider 和 web.fetchProvider 选择各个提供方,「网页搜索与获取」页上的 Search 和 Fetch 下拉框分别设置这两项;内置组合选择本地 HTTP 抓取,不选择搜索提供方,此时 DeepSeek 模型路由之外的搜索使用 Search API,见选择决策。已保存的选择从下一次操作起生效,因为 Web 服务在每次操作时读取两项选择。每次操作解析一份包含端点和凭据的设置快照。两个 API 读取 web-deepseek-api namespace,每个能力各自解析端点与凭据。
直接检索在 API 基础地址后追加 /search 或 /fetch。没有在 YAML 中单独设置端点字段的能力,使用会话的 DeepSeek 模型路由基础地址的 origin 加 /v1/tools,公网部署即指南中的 https://api.deepseek.com/v1/tools;该推导及每次操作发送的凭据由选择决策负责。已验证的开发地址为 http://api-dev.deepseek.com:8031/api/v1/tools;其前缀不同,程序不会根据主机名推断,此类部署需在 searchBaseURL 或 fetchBaseURL 中填写完整基础地址。基础地址无法解析时,该能力的提供方不可用。
指南规定使用 API 密钥进行 Bearer 鉴权,请求只发送文档规定的鉴权与 JSON 内容类型请求头。deepseek-account 路由上的会话改为发送账号 token;2026-10-16 公网 Search 与 Fetch 路由已接受该 token,因此只登录账号的用户也能使用直接检索。同日检查的一个 Anthropic 兼容网关提供 Messages 网页搜索,但没有 /v1/tools 路由;此类部署可以选择 Messages 搜索,或把该能力的单独基础地址设为提供 /v1/tools 的地址。
搜索结果与模型输入
直接 Search 发送 query、count、need_content: false 和 ori_question。count 为 1 至 50 的配置值,默认采用服务的 10;请求的结果上限更小时以后者为准,工具总会发送其上限,默认为 8。ori_question 是发起会话中最近一条用户提示的文本,空白折叠后截取至 API 的 128 个字符上限。API 拒绝空白或更长的值,因此没有此类提示的搜索不发送该字段,sendOriginalQuestion: false 可将其关闭。2026-10-16 的探测中,不同取值未改变结果顺序、评分或摘要。查询原样传递,包括文档中的站点、语言、日期、排除和精确短语操作符。服务端执行查询长度为 1–128 个 Unicode 字符的约束。空 results 表示成功。
提供方保留服务端顺序,将 URL、标题、snippet、summary 和可为 null 的 date 映射为共享来源。按照指南,工具把每个来源的 summary 提供给模型,短的 snippet 留给搜索卡片及其回放元数据。指南中的典型摘要长度不是最大值:2026-10-16 实测返回的摘要为 1,000–2,300 个字符。因此 dsh-tool-web 合并摘要中的空白,并将每条摘要限制在 searchSummaryMaxChars 以内,默认 800 个字符,即指南典型范围的上限;一次调用的摘要总长不超过来源上限乘以该上限。摘要随工具输出值和渲染文本一起进入 Session 记录。提供方不使用完整 content、site_name、site_icon、rerank_score 或 authority,也不发送 localization。这些是当前接入的限制,并非 API 缺少这些能力。
直接检索不产生辅助模型请求事件,因为 Harness 没有发起该请求。普通工具调用与工具结果事件继续保留查询及模型可见的结果。这不代表搜索服务内部不使用模型。返回文本仍是外部不受信任的数据。
抓取元数据与职责
Fetch 发送 URL,返回 Markdown,无需 Harness 额外发起摘要请求。API 既不提供重定向后的最终 URL,也不提供目标 HTTP 状态,而共享结果没有标题字段。提供方保留请求 URL,返回 Markdown 正文,并对成功响应报告 HTTP 200:URL 不可用、被站点策略拦截、目标站点返回错误或无法提取 Markdown 时,Fetch API 会返回 404。2026-10-16 无法解析的主机实际返回 HTTP 500,因此任何非成功状态都视为抓取失败,而不是对目标的具体诊断。共享抓取结果及其消费方保持不变。
HTTP 提供方继续负责自身的 URL 校验和资源限制。选择 DeepSeek 会将页面抓取与目标访问策略交给该服务;Harness 拒绝 API 请求重定向,并保留取消与工具输出限额。因此报告的 HTTP 200 表示服务已获取页面,而不是 Harness 观察到了目标响应。指南中的 Fetch 403 表示抓取器策略拒绝,404 则表示没有可用的页面内容。
默认值迁移
内置组合不固定搜索提供方:为 DeepSeek 模型路由上的模型请求发起的搜索运行 Messages 搜索,其他路由上的搜索运行 deepseek-search-api;选择决策负责这项默认值及其不回退规则。API 密钥和账号 token 都能访问公网路由。位于没有 /v1/tools 路由的网关之后的部署,需把 searchBaseURL 设为提供这些路由的基础地址。已保存的 web.searchProvider: deepseek-official 会选中 Messages 搜索,其他已保存的选择保持其提供方。
旧版 Messages 搜索
选中 deepseek-official 时,独立的 dsh-web-search-deepseek 提供方发送 Messages 搜索请求,见选择决策。它的 web/deepseek-search-llm-request 会话事件类型(包括持久化确认记录覆盖的可选请求体字段 thinking: { type: 'disabled' })仍由 dsh-web-search-deepseek 声明并写入,因此包含该事件的已发布会话仍能打开。Messages 搜索发送该字段,是因为 Harness 丢弃生成的回答,辅助请求无需推理。
考虑过的替代方案
仅保留 Messages 搜索实现。 即使调用方只需要来源,这也保留了辅助生成和响应提取。直接 Search 去掉这次 Harness 模型请求。
复用 Messages 地址或推断路由前缀。 协议与部署前缀不同。分别保存基础地址可保留现有配置,避免把有效请求发往错误路由。
要求显式填写 Search API 基础地址。 Search API 是 DeepSeek 模型路由之外内置的搜索默认值,空默认值会让它在每位用户填写一个 DeepSeek 模型路由已经确定的地址之前都不可用。其他部署仍可设置自己的基础地址。
把两个 API 放在 Messages 提供方内部,由提供方自己的开关切换。 Messages 提供方内的开关无法改变抓取路由,因此除非用户另外修改 web.fetchProvider,web_fetch 仍会走 HTTP;它还会把两个 API 的生命周期绑在 Messages 搜索上。独立注册让 Web 服务通过现有的提供方选择机制选择各个提供方,不会把任一 API 与 Messages 提供方绑定。
让 Messages 搜索与新 API 共用一套传输层。 共享 Web 传输层会耦合不同的请求格式和失败映射。凭据改为来自同一个服务 ctx.deepseekAuth,它释放 API 密钥或账号登录凭据的请求头;Messages 搜索与 Search/Fetch API 传输层保持独立。
把 Search 和 Fetch 拆成两个包。 指南从同一基础地址、以同一份凭据提供两个 API;拆成两个包会让指向同一部署的设置重复出现。分别选择不需要拆包,因为每个 API 注册自己的提供方 id。每种操作位于独立模块,任一 API 都可以单独修改。
在设置页用下拉框列出所有已注册的提供方。 通用提供方表单从 Config schema 推导编辑控件,还需要在提供方接口上增加宿主侧展示元数据。这一否决对通用表单仍然成立:该页面只编辑 DeepSeek 提供方的设置,其他提供方保留各自的设置页。对于提供方下拉框,选择决策取代了这一否决,下拉框按 title 列出所有已注册的提供方。
让模型以工具参数提供 ori_question。 API 将该字段定义为用户的原始问题,而最近一条用户提示已记录了这段文本。工具参数会改变所有搜索提供方共用的面向模型的 schema,并引入改写。
新增提取工具或扩展抓取结果。 API 以 Markdown 获取一个具体网页,符合现有抓取操作。其成功本身即表示已获取页面,Markdown 正文也带有页面标题,因此扩展结果会改动每个抓取消费方,而模型可见的收益很小。
影响
直接检索不需要辅助模型 token,但结果仍消耗主模型上下文。2026-10-16 通过网关进行的一次 Messages 网页搜索,为一次服务端搜索消耗了 8,154 个输入 token 和 828 个输出 token。指南对 Search 和 Fetch 分别按每 1,000 次成功且有结果的请求收取 5 元;结果条数不影响单次价格。多个查询仍对应多次请求。文档中的 Claude Code 与 Codex 优惠不能作为 Harness 免收费用的依据。除非关闭 sendOriginalQuestion,Search API 模式还会随每个查询把用户提示的至多 128 个字符发送给搜索服务。
Search 和 Fetch 各有账号级 5 QPS 限制,独立于模型并发,同一账号的 API 密钥共享额度。Fetch 还有目标域名限制。工具每次调用最多接受 searchMaxQueries 个查询,默认 10 个;任一查询失败会使整批失败。Search 提供方在单个插件实例的任意一秒窗口内最多发送 searchRequestsPerSecond 个请求,默认 5 个,因此满批次的后五个查询比前五个晚一秒开始。该限速不跨进程共享,提供方也没有自动重试或回退;其他进程或客户端也会消耗同一账号的额度。
验证与尚未接入的 API 能力
提供方测试覆盖请求映射、空结果、格式错误的响应、独立地址与推导地址、账号 token 鉴权及其在 HTTP 401 后被作废、取消与空白配置。设置测试及插件配置浏览器场景覆盖暂存后保存、结果数,以及分别选择 Search 与 Fetch。网页搜索回放与 Fetch Session 回放固定模型可见结果。2026-10-16,真实提供方测试在公网地址通过了 Search 与 Fetch 验证;在内置配置上运行的一轮 headless 对话返回了八个来源并抓取到 Markdown,且没有辅助请求事件。上文的账号 token、网关和状态码观察来自同日的手动探测。
以下能力尚未包含在已实现的接入中:
- 在适用于提供方的工具说明中介绍搜索语法,先定义有界的本地化输入,再进行转发。API 的
localization是 IP 地址,不能用推测的城市或界面语言代替。 - 先保留质量元数据,再定义筛选策略。
rerank_score与authority表示服务端评估,不保证内容真实;固定阈值可能丢弃有用的冷门来源。 - 增加支持取消的调度并明确有限重试的职责。指南建议对 408、429 和 5xx 等待后重试;402 需要先充值,其他 4xx 需要修改请求。本地节流无法跨无关进程执行账号级配额。