
DeepSeek Search 和 DeepSeek Fetch 现在可通过 AI Gateway 使用。Search 会查找相关页面,并返回标题、URL 和摘要。Fetch 会以 Markdown 形式获取页面内容,供你的模型读取。
只需一个 AI Gateway API key,即可在任何支持工具调用的模型上使用这两个工具。无需单独的 DeepSeek 账号,切换模型提供商时也可以保留相同的工具。
这些辅助工具在 v6 上需要 AI SDK 6.0.321 及更高版本,在 v7 上需要 7.0.160 及更高版本。使用 pnpm add ai@latest 更新,并设置你的 AI_GATEWAY_API_KEY。要组合使用搜索和页面抓取,请在 tools 中传入这两个辅助工具:
import { gateway, streamText } from 'ai';const result = streamText({ model: 'deepseek/deepseek-v4.1-flash-1017', prompt: 'Find the latest Vercel AI Gateway announcement, fetch it, and summarize it.', tools: { deepseek_search: gateway.tools.deepseekSearch({ count: 3 }), deepseek_fetch: gateway.tools.deepseekFetch(), },});for await (const text of result.textStream) { process.stdout.write(text);}
如果 DeepSeek Search 失败,你也可以将其他搜索工具与 DeepSeek Fetch 搭配使用:
import { gateway, streamText } from 'ai';const result = streamText({ model: 'zai/glm-5.3-flash', system: 'Try deepseek_search, then exa_search, then parallel_search on errors. After search succeeds, use deepseek_fetch on a result URL.', prompt: 'Find the latest Vercel AI Gateway announcement, fetch it, and summarize it.', toolChoice: 'required', tools: { deepseek_search: gateway.tools.deepseekSearch({ count: 3 }), deepseek_fetch: gateway.tools.deepseekFetch(), exa_search: gateway.tools.exaSearch({ numResults: 3 }), parallel_search: gateway.tools.parallelSearch({ maxResults: 3 }), },});for await (const text of result.textStream) { process.stdout.write(text);}
搜索回退由模型主导,因此提供商顺序和重试次数均为尽力而为。DeepSeek Fetch 可以抓取上述任一搜索工具返回的结果 URL。
Search 和 Fetch 各按每 1,000 次计费请求 $0.75 收费。失败请求、超时和空结果不收取工具费用。模型 token 另行计费。
有关配置选项和定价详情,请参阅 DeepSeek Search 文档和 DeepSeek Fetch 文档。
AI Gateway 提供一个 API,用于调用模型、跟踪用量与成本,以及配置路由、重试和故障转移。你可以使用 AI Gateway API key,或自带提供商密钥。