Web Search
Use the built-in webSearch tool to let the model search the web for real-time information.
webSearch is a built-in web search tool in deepseek-kit, powered by the DeepSeek Anthropic-compatible endpoint. It enables the model to search the web for real-time information — recent events, current data, documentation lookups, or fact-checking — breaking through the limitations of training data.
Basic Usage
Call webSearch() directly to create a tool, then pass it to an agent:
You can also use it with generateText:
Configuration Options
webSearch() accepts an optional configuration object:
thinking('enabled' | 'disabled', default'enabled') — Whether to enable thinking mode. When enabled, the model reasons before searching, improving the quality of search results.maxTokens(number, default32768) — Maximum number of tokens for the search response.
How It Works
The webSearch workflow is as follows:
- Sends the user query to the DeepSeek Anthropic-compatible endpoint (
https://api.deepseek.com/anthropic) - Uses Anthropic's
web_search_20250305tool to perform the search - The model generates a summary answer based on the search results
- Returns formatted search results, including a summary and source links
The returned result includes:
- Search result summary — A comprehensive answer generated by the model based on search results
- Source list — Titles, URLs, and page dates of the found web pages
Combining with Other Tools
webSearch can be used alongside other tools. The model will autonomously choose which tool to call based on context:
Cancellation Support
webSearch supports cancellation of in-progress search requests via AbortSignal:
API Reference
WebSearchOptions
'enabled'32768
