Executable programs and extensions
Last updated
DeepSeek Search and Fetch API: giving a local LLM web results
Call search and page fetch separately, then put the returned summaries into the local model's prompt.
DeepSeek's Search API1 returns a list of web pages for a query, and the Fetch API returns one page's body as Markdown. Both use the same API key and cost $0.75 per 1,000 successful requests each. Rather than forcing a local model to call tools, let your app search first and put the top summaries and URLs into the prompt2; it is simpler and easier to reproduce.
Search and page fetching are separate APIs
The Search API returns a list of web pages matching a query, and the Fetch API returns the body of one URL as Markdown. Both sit under https://api.deepseek.com at /v1/tools/search and /v1/tools/fetch, and both use a DeepSeek API key as a bearer token3. Search alone does not give you the full page, so decide first whether a summary is enough or you need the body.
Search accepts a query of 1 to 128 characters and returns 1 to 50 results, 10 by default. Setting need_content includes page bodies in the response, which makes it much larger. ori_question takes the original question, up to 128 characters, to improve ranking.

Read the ranking score and summary first
Each result carries rerank_score (0 to 3), authority (0 to 4), date, summary (usually 600 to 800 characters) and content. A score of 1.5 or above is described as high quality, and an authority of 3 or above marks a highly authoritative source. Keep the summary, URL and date together in the prompt so citations stay easy.
| Field | Value | Use |
|---|---|---|
rerank_score | 0~3 | Ranking the top results |
authority | 0~4 | Source authority |
summary | 600 to 800 characters | Summary for the prompt |
content | When need_content is set | Checking part of the page |
Feed the local model with search results, not tool calls
Handing tool calls4 to a local model makes schema mistakes and repeated calls more likely as the model gets smaller. A simpler pattern is for your app to search first, put the top three to five summaries into the prompt with citation numbers, and ask the local model to answer only from that material and say when it does not know.
For questions that need the source text, fetch only the URLs you selected and trim the body. Keep the paragraphs that matter to the question, and record each URL and fetch time. The retrieval step then stays reusable when you change models.
curl https://api.deepseek.com/v1/tools/search \
-H "Authorization: Bearer $DEEPSEEK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query":"DeepSeek V4.1 Flash 1017","count":5}'Billing counts successful requests
Search and Fetch each cost $0.75 per 1,000 successful requests. Forty searches and twenty fetches a day come to 1,200 searches and 600 fetches a month, about $1.35. Failed requests are not billed, but a retry that succeeds does count.
Calls made as server-side tools from DeepSeek Harness, Claude Code or Codex are free until 00:00 Beijing time on November 1, 2026. After that the same calls are billed per request, so recording your volume during the free window makes the post-change cost easier to estimate.
| API | Unit | Price |
|---|---|---|
| Search | 1,000 successful requests | $0.75 |
| Fetch | 1,000 successful requests | $0.75 |

Handle Fetch failures by cause
Fetch can return 403 when the target site blocks it, 404 when no usable body is available and 500 when the address cannot be resolved. An empty balance returns 402. Retrying the same URL rarely changes a 403 or 404, so switch sources or fall back to the search summary.
A URL cannot carry a username or password, and the API must not be used to get around a site's access policy. Retry only 5xx responses, briefly, and cache successful URLs with a body hash to avoid paying repeatedly for the same page.
What to log before production
Log the query, the URLs you used, the fetch time, the model and the prompt version. Search results change over time, so you need the material as it looked when the question was asked. Before putting personal or internal content into a query, decide what is allowed to leave your network.
When storing response bodies, check copyright and site terms and keep only the length you need. With a local model plus this API, the model runs on your machine but queries and URLs still leave it; tell users that plainly.

Terminology notes
API — A defined interface that lets other code call a program’s functions.
Back to the textPrompt — The input text sent to a model. For generative models it describes the desired result and strongly shapes the output.
Back to the textToken — A unit into which a model divides input or output for processing.
Back to the textTool call — A structured request from a model for an external function such as reading a file, searching, or running a command. The agent runtime and its permission settings decide whether the request is actually executed.
Back to the text
Frequently asked questions
- What should you check first in this article?
- DeepSeek's Search API returns a list of web pages for a query, and the Fetch API returns one page's body as Markdown. Both use the same API key and cost $0.75 per 1,000 successful requests each. Rather than forcing a local model to call tools, let your app search first and put the top summaries and URLs into the prompt; it is simpler and easier to reproduce.
Read next
read first
Local RAG Setup Guide: Build an AI That Answers from Your Documents
Executable programs and extensions
When local RAG answer is wrong: Search, chunk, model diagnosis order
Model setup recipes
A task-harness design example for a local coding agent
Executable programs and extensions
How to Back Up and Restore a Local LLM You Already Use
