
您打开了DeepSeek控制台,粘贴了“写一封营销邮件”,得到了一些通用的内容。问题不在于模型,而在于提示。经过六个月在DeepSeek V4-Pro和V4-Flash上通过生产工作负载——提取管道、代码审查、法律文件的RAG(阅读-询问-生成)、每周报告——运行后,我收集了一组DeepSeek提示模板库,这些模板始终优于临时请求。它们简短、结构化,并调整到DeepSeek文档实际推荐的参数。
本文为您提供了12个复制粘贴模板,按任务组织——提取、代码、推理、写作、代理工具使用——以及使它们工作的温度设置、系统提示结构和JSON模式注意事项。自2026年4月24日V4预览发布以来,每个模板都已针对`deepseek-v4-pro`和`deepseek-v4-flash`进行测试。
为什么在 DeepSeek V4 上提示模板更重要

DeepSeek 提示模板库
23 tested-shape prompt skeletons that work reliably on V4. Search, filter by category, copy, fill the {placeholders}, send.
每个模板都使用XML标签——DeepSeek V4可以可靠地解析这些标签。在发送前替换每一个。 {placeholder} 。
V4改变了规则。旧版模型名称 deepseek-chat and deepseek-reasoner 将于2026-07-24被弃用,并且它们现在对应于 deepseek-v4-flash 分别。这次迁移对模板很重要,因为思维不再是单独的模型——它是在两个模型中的请求参数。 deepseek-v4-pro or deepseek-v4-flash的非思考模式和思考模式。相同的提示根据是否设置了 reasoning_effort="high" with extra_body={"thinking": {"type": "enabled"}},或者关闭它,会产生可测量的不同输出。
V4的另一项变化是上下文。两个层级默认为1,000,000个令牌的窗口,输出最多384,000个令牌。这意味着模板可以更长,包含更多示例,嵌入更多参考资料,比V3.2上的更多。但如果你不结构化长提示,那么它们也会成为浪费。我们将在下面介绍缓存友好的布局。
关于底层模型的背景信息,请参阅 DeepSeek V4-Pro and DeepSeek V4-Flash如果您想深入了解提示理论而不是现成的模板,请参阅配套文章。 DeepSeek prompt engineering 是更好的起点。
四块模板结构
本文中的每个模板都遵循相同的四块布局。这是我找到的最容易维护的结构,也是上下文缓存指纹识别最容易的结构。
- 系统模块 ——角色、约束、输出格式。在调用之间保持稳定。
- 参考块 — 架构s, examples, retrieved 文档s. Mostly stable.
- 任务块 —— 本回合要做什么。每次调用可能发生变化。
- 用户输入 —— 易变内容(一个问题、一个文件、一行数据)。
块1和2属于 system 消息或第一条 user 消息的前面。块3和4放在后续 user 消息。因为默认温度是1.0,DeepSeek建议根据每个用例进行调整——代码和结构化分析接近0.0,一般对话约为1.3,创意工作高于1.0,以下每个模板都将提示与推荐的温度配对。
与每个模板搭配的温度设置
| 任务类型 | Temperature | Notes |
|---|---|---|
| 代码生成、数学 | 0.0 | 确定性,更少的幻觉API |
| 数据 提取ion, 清理ing | 1.0 | DeepSeek’s 推荐ed setting for analytical work |
| 通用问答、翻译 | 1.3 | 默认的;平衡的 |
| Creative writing, poetry | 1.5 | 需要更多样性和更多修订 |
这些与DeepSeek官方在API参数文档页面上的指导一致。选择一个并坚持用于该模板——不要同时推送 top_p; DeepSeek和与OpenAI兼容的规范通常建议调整温度或top_p,但不要两者都调整。
模板 1 — 结构化提取(JSON 模式)
当你需要文本输出时使用此功能。DeepSeek API使用与OpenAI/Anthropic兼容的格式,因此你可以通过更改配置来使用OpenAI SDK针对DeepSeek基本URL。设置 response_format={"type": "json_object"}, set max_tokens 足够高以避免截断,并在提示中包含“json”一词以及一个小示例模式。
System:
You are a 结构化-数据 提取or. Return only valid JSON matching the 架构.
Do not include prose. If a field is unknown, return null.
Schema (example):
{
"company": "Acme Inc",
"amount_usd": 12500.00,
"invoice_date": "2026-04-12",
"line_items": [{"sku": "A-1", "qty": 2, "price": 19.99}]
}
User:
Extract a json record from the 电子邮件 below. Use the 架构 above.
[paste 电子邮件]
JSON模式旨在返回有效的JSON,但不保证。模型偶尔会返回空内容,因此请在解析时进行重试。完整警告已在文档中说明。 DeepSeek API JSON mode 指南。推荐模型: deepseek-v4-flash,非思考模式,温度1.0。
模板 2 — 带约束的代码生成
代码是温度-0设置发挥作用的地方。告诉模型语言、运行时、允许的库以及不想要的故障模式。
System:
You are a senior Python engineer. Write Python 3.12 code only.
所有owed libs: stdlib, httpx, pydantic. No requests, no global state.
Return one fenced code block plus a 3-line explanation.
User:
Write a function fetch_invoices(api_key: str, since: date) -> list[Invoice]
that pages /v1/invoices?since=... and returns a list of Pydantic Invoice
models with id, amount_cents, currency, paid_at fields.
For multi-file 代码重构s, switch to deepseek-v4-pro with thinking enabled. Pair this template with the workflow 描述d in DeepSeek for coding.
模板 3 — 思维模式下的推理

思考模式是一个参数,而不是一个模型。对于最困难的问题,设置 reasoning_effort="high" and extra_body={"thinking": {"type": "enabled"}}; the response returns reasoning_content alongside the final content. Use "max" —— 文档指出这需要 max_model_len >= 393216 to avoid truncation.
System:
You are a careful analyst. Think through the problem step by step in
reasoning_content. In content, return only the final answer in the
format requested.
User:
A SaaS charges $0.14 per 1M input tokens and $0.28 per 1M output.
We make 1M calls/day, each with 2,000 cached input + 200 fresh input
+ 300 output tokens. Cache-hit input is $0.0028/M. What is the daily
spend, broken down by bucket? Return a markdown table.
这就是本文前面提到的V4-Flash工作示例——每日总额为117.60美元(缓存5.60美元,缺失28美元,输出84美元)。展示数学计算胜过信任任何单一模型输出。
模板 4 — 缓存友好的系统提示
上下文缓存将V4-Flash的输入成本从每百万个标记0.14美元降低到0.0028美元,并将V4-Pro的列表价格从1.74美元/列表降至0.0145美元/列表,促销价格从0.435美元降至0.003625美元,直至2026年5月31日。当DeepSeek检测到重复的前缀时,缓存命中价格将自动应用。要触发它,请保持调用之间的前缀位相同。
- Put the entire static instruction set, 架构s, and few-shot examples in
消息中(系统)或消息的最前面消息中(用户)。 - 请勿将时间戳、请求ID或每个用户的名称插入到前缀中。
- 如果用户特定的位必须提前出现,请将其推入后续消息中,并保持系统块稳定。
关于缓存命中实际节省的数学计算,请参考 DeepSeek context caching 中的示例。
模板 5 — 引用来源的RAG(阅读-询问-生成)
System:
You answer questions only from the provided sources. Cite each claim
with the source id in square brackets, e.g. [S2]. If the sources do
not contain the answer, 回复: "Not in sources." Do not invent facts.
Sources:
[S1] {chunk 1 text}
[S2] {chunk 2 text}
[S3] {chunk 3 text}
User:
{question}
与检索功能配合使用,如 DeepSeek RAG(阅读-询问-生成) tutorial. Temperature 1.0; deepseek-v4-flash 中所述,对于大多数检索来说是可以的,当答案必须全面时,升级到V4-Pro。
模板 6 — 长文档摘要
在1M标记的上下文中,您很少需要分块只是为了适应。您仍然需要指导哪些内容需要总结。
System:
Summarise the 文档 in three layers:
1. One-sentence verdict
2. Five bullet key findings, each <= 20 words
3. Risks and unknowns, with section references like (p. 12)
Do not editorialise. Do not add information that is not in the 文档.
模板 7 — 基于角色的批判
角色提示之所以有效,是因为它们限制了词汇范围以及模型视为相关的内容。请具体说明。
You are a 数据base administrator with 15 years of Postgres experience.
Review the SQL below. List, in order of severity:
1. Correctness bugs
2. Performance issues at > 10M rows
3. Style problems
For each, quote the offending line and propose a fix.
模板 8 — 工具调用骨架
在OpenAI格式中,函数调用是可行的。声明工具,让模型发出工具调用,在客户端运行调用,并将结果附加到 messages,然后再次调用。API是无状态的——聊天请求击中 POST /chat/completions,OpenAI兼容的端点,并且你必须在每个回合重新发送对话历史。
from openai import OpenAI
client = OpenAI(base_url="https://api.deepseek.com", api_key="...")
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
resp = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Weather in Dublin?"}],
tools=tools,
)
完整模式请参见 DeepSeek API function calling.
模板 9 — 带有语域控制的翻译

Translate the text below from English to {target}.
Register: {formal|conversational|technical}.
Preserve: code blocks, URLs, numbers, proper nouns.
Output only the translation, no commentary.
温度设置为1.3产生的输出比0更自然;官方文档将1.3标记为推荐的翻译设置。
模板 10 — 创意写作大纲
Write a {format} of {length} words about {topic}.
Audience: {who}. Tone: {adjective + adjective}.
Constraints: {must include}. Avoid: {must not}.
Provide two distinct 草稿s, then a one-line note on the difference.
温度设置为1.5。如果两个草稿感觉相同,提高到1.7或重新运行——V4在低温下可能会锁定在单一声音上。
模板 11 — 测试用例生成器
For the function signature below, generate pytest 测试 covering:
- Happy path (3 cases)
- Edge cases (empty, single element, max size)
- Error cases (invalid type, out-of-range)
Return one fenced code block. No commentary.
{paste signature + docstring}
模板 12 — 自我批判环节
Cheap on V4-Flash, often worth running. The first call 草稿s; the second 批评s and 重写s.
Pass 1 (temperature 1.3): Draft the response.
Pass 2 (temperature 0.0): "Critique the 草稿 below for factual errors,
weak claims, and structural problems. Rewrite to fix them. Output only
the rewritten version."
端点和参数参考
上述每个模板都发送到 POST /chat/completions at https://api.deepseek.comDeepSeek的API与OpenAI和Anthropic兼容,因此您可以在任一SDK中交换基本URL和密钥。上述模板中出现的参数:
model—deepseek-v4-proordeepseek-v4-flashtemperature—参见上表max_tokens—使用JSON模式时,将其设置为高(例如8000+)reasoning_effort—"high"or"max"withextra_body={"thinking": {"type": "enabled"}}response_format—{"type": "json_object"}—针对模板1tools—针对模板8stream—对于聊天用户界面为真
—关于设置,请参阅 how to get a DeepSeek API key—有关包括提示生成器在内的更广泛工具集,请参阅 DeepSeek tools and utilities hub.
我不会做什么

- —系统提示中的行内时间戳——杀死缓存命中。
- —设置两者
temperatureandtop_paggressively — 选择 one. - 使用思考模式回答简短的事实性问题——您将支付不需要的输出令牌费用。
- 信任JSON模式而不使用解析器回退——它是“设计用来”返回JSON的,但不保证。
- 引用第三方博客中的单个SWE-Bench数字,但不要检查分割情况(验证版 vs 完整版 vs 轻量版)。
DeepSeek AI Guide is an independent resource and is not affiliated with DeepSeek or its parent company. Model IDs, pricing and API behaviour change; check the official DeepSeek 文档ation and pricing page before 提交ting to a production 决策.
Frequently asked questions
我该如何为DeepSeek V4编写系统提示?
摘要>将角色、约束和输出格式放入 system 消息并保持其在调用间位相同,以便上下文缓存可以命中。在同一块中添加模式或少量示例。将易变内容(时间戳、用户名、今天的问题)保存以供后续使用。 user 消息。我们使用的是四块结构的消息。 DeepSeek prompt engineering 指南适用于V4-Pro和V4-Flash。
我应该使用什么温度与DeepSeek提示模板一起使用?
摘要>DeepSeek的文档建议代码和数学为0.0,数据分析为1.0,一般对话和翻译为1.3,创意写作为1.5。默认值为1.0。将温度与您正在运行的模板相匹配——代码模板为0.0,创意模板为1.5。更多指导信息请参阅。 DeepSeek API best practices reference.
我可以使用相同的提示为V4-Pro和V4-Flash使用吗?
摘要>是的——两个级别共享相同的API界面和提示格式。区别在于成本和能力上限:V4-Pro在输出上大约是V4的六到七倍,对于前沿编码或代理工作来说物有所值。对于聊天、提取和大多数RAG(阅读-询问-生成),V4-Flash是默认选项。在上比较两者。 DeepSeek pricing calculator.
DeepSeek JSON模式是否能保证有效的JSON输出?
摘要>不。DeepSeek的文档描述JSON模式是为了返回有效的JSON,但不保证。模型偶尔可能会返回空内容,因此始终在try/except中包装解析并重试。在提示中包含“json”一词以及一个示例模式,并设置 max_tokens 足够高,以至于响应不会在对象中间被截断。 DeepSeek API JSON mode 文档详细介绍了故障情况。
为什么我的DeepSeek提示模板比预期更贵?
摘要>几乎总是以下三种情况之一:系统提示在调用之间发生变化(无缓存命中)。 max_tokens 限制未开启,因此思考模式会产生大量痕迹,或者您正在使用 V4-Pro 而不是 V4-Flash。请检查令牌计数。 DeepSeek token counter and 审查 the cost breakdown by bucket — cached input, uncached input, and output — separately.
Sources & Methodology
Primary sources
- OfficialDeepSeek API 文档ationEndpoints, request/response shape, model IDsLast checked: April 30, 2026
- PricingDeepSeek API pricing pagePer-1M-token rates, billing units, cache-hit pricingLast checked: April 30, 2026
- Model cardDeepSeek V4-Pro model card on Hugging Face推理-effort settings used in prompt-template 推荐ationsLast checked: April 30, 2026
Technical references
- Technical reportDeepSeek-V3 technical report (arXiv:2412.19437)V3 architecture and training methodologyLast checked: April 30, 2026
Methodology
Information in this 文章 was checked against the official DeepSeek 文档ation, the 文章's cited primary sources, and the deepseekai.guide pricing 数据set on the date shown above. Where third-party numbers are quoted, the originating source is linked inline so the reader can verify and re-check.
数据 置信度
High for facts cited inline with primary-source links; medium for context narrative.
Editorial note
AI tooling moves quickly. If you spot an outdated number or a broken link, the contact link in the footer is the fastest way to flag it for the editorial team.