返回资讯中心
外部精选
软件工程
#开发者实时流

DeepSeek 发布聊天与网页工具 API,支持联网搜索和文件读取

来源标题:DeepSeek releases chat, web tools API

DeepSeek 推出聊天与网页工具 API,开发者可调用与 DeepSeek Chat 相同的对话功能。这些功能包括联网搜索、深度思考搜索、文件输入和 URL 读取,以及对模型内容安全的基本风险控制,可通过 Messages、Responses 和 Chat Completions 三种 API 使用。DeepSeek 同时提供开源演示聊天客户端,API 密钥与对话数据仅存储在浏览器中。

Hacker News 最新anigbrowl2026/11/14 · 3 天前14 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Build a Chatbot

Overview

On this page

Copy MarkdownCopy Markdown

Open Markdown

Build a Chatbot

The DeepSeek API offers the same conversation features as DeepSeek Chat on the web and in the app: web search, deep thinking search, file input and URL reading, plus basic risk control for model content safety. You can use them to build your own chatbot.

The service runs the searches and URL reading. Your client only shows the returned blocks and passes them back unchanged in the next round.

DeepSeek provides an open-source demo chat client that shows how to build a chatbot with these APIs. Enter your API key to start. You can also import the chat history you exported from DeepSeek Chat and continue your conversations.

Your API key, conversations and uploaded images are stored only in your browser. The demo is for demonstration only.

The chat features are available in the Messages API, the Responses API and the Chat Completions API.

A streaming request with the web tools, safety review and the conversation title enabled:

curl https://api.deepseek.com/anthropic/v1/messages
-H "Content-Type: application/json"
-H "x-api-key: ${DEEPSEEK_API_KEY}"
-d '{ "model": "deepseek-flash", "thinking": {"type": "enabled"}, "tools": [ {"type": "deepseek_web_search", "name": "deepseek_web_search"}, {"type": "deepseek_read_url", "name": "deepseek_read_url"} ], "safety_check": {"level": "high"}, "title": {"enabled": true}, "messages": [{"role": "user", "content": "What is new in DeepSeek V4.1?"}], "stream": true }'

The stream of this request, shortened:

event: message_start data: {"type":"message_start","message":{"id":"b161a9be-...","type":"message","role":"assistant","model":"deepseek-flash","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":40,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":0,"service_tier":"standard"}}}

event: content_block_start data: {"type":"content_block_start","index":0,"content_block":{"type":"thinking","thinking":"","signature":""}}

event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"thinking_delta","thinking":"..."}}

event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"signature_delta","signature":"b161a9be-..."}}

event: content_block_stop data: {"type":"content_block_stop","index":0}

event: content_block_start data: {"type":"content_block_start","index":1,"content_block":{"type":"server_tool_use","id":"srvtoolu_ds_00_b2baebaf...","name":"deepseek_web_search","input":{"action":"search","queries":["DeepSeek V4.1 new features","DeepSeek V4.1 release notes"]},"caller":{"type":"direct"},"kind":"deep_search"}}

event: content_block_stop data: {"type":"content_block_stop","index":1}

event: content_block_start data: {"type":"content_block_start","index":2,"content_block":{"type":"web_search_tool_result","tool_use_id":"srvtoolu_ds_00_b2baebaf...","content":[{"type":"web_search_result","title":"...","url":"https://api-docs.deepseek.com/news/news261017/","encrypted_content":"...","page_age":"2026-10-16T16:00:00+00:00","snippet":"...","site_name":"DeepSeek","site_icon":"https://cdn.deepseek.com/site-icons/deepseek.com"}],"kind":"deep_search"}}

...

event: content_block_start data: {"type":"content_block_start","index":15,"content_block":{"type":"text","text":""}}

event: content_block_delta data: {"type":"content_block_delta","index":15,"delta":{"type":"text_delta","text":"Deep"}}

event: content_block_delta data: {"type":"content_block_delta","index":15,"delta":{"type":"citations_delta","citation":{"type":"web_search_result_location","url":"https://api-docs.deepseek.com/news/news261017/","title":"...","encrypted_index":"","cited_text":"..."}}}

...

event: message_delta data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null,"title":"..."},"usage":{"input_tokens":9078,"cache_creation_input_tokens":0,"cache_read_input_tokens":4096,"output_tokens":1686,"service_tier":"standard","server_tool_use":{"web_search_requests":1,"web_fetch_requests":0,"tool_search":2,"tool_fetch":0,"tool_image_search":0}}}

event: message_stop data: {"type":"message_stop"}

curl https://api.deepseek.com/responses
-H "Content-Type: application/json"
-H "Authorization: Bearer ${DEEPSEEK_API_KEY}"
-d '{ "model": "deepseek-flash", "reasoning": {"effort": "high"}, "tools": [ {"type": "deepseek_web_search"}, {"type": "deepseek_read_url"} ], "safety_check": {"level": "high"}, "title": {"enabled": true}, "input": "What is new in DeepSeek V4.1?", "stream": true }'

curl https://api.deepseek.com/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer ${DEEPSEEK_API_KEY}"
-d '{ "model": "deepseek-flash", "thinking": {"type": "enabled"}, "tools": [ {"type": "deepseek_web_search"}, {"type": "deepseek_read_url"} ], "safety_check": {"level": "high"}, "title": {"enabled": true}, "messages": [{"role": "user", "content": "What is new in DeepSeek V4.1?"}], "stream": true }'

Render a Response​

A chatbot response contains several kinds of content blocks. The screenshot below marks where each block appears in DeepSeek Chat.

See Web Tools and Model Content Safety for the block formats.

When a request declares deepseek_web_search or deepseek_read_url, sets safety_check to high, or enables title, the service decides the following parameters, and the values in the request are ignored:

max_tokens (max_output_tokens in the Responses API) works as usual. It limits the output of each inference step in a round, not the total output of the round.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →