deep-research
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDeep Research (via DeepAPI)
深度研究(通过DeepAPI)
We use DeepAPI (deepapi.co) for all deep research. This fully replaced the retired skill that called OpenRouter/Perplexity directly.
perplexity-deep-research我们使用DeepAPI(deepapi.co)完成所有深度研究工作。它已完全取代了直接调用OpenRouter/Perplexity的已停用技能。
perplexity-deep-researchAPI key
API密钥
- Read from the environment; setup writes it to
DEEPAPI_API_KEY.~/.deepapi/env - Gotcha: do NOT — it breaks the shell (exit 126). Use the env var if set, else load the platform file:
source ~/.zshrc
bash
[ -n "$DEEPAPI_API_KEY" ] || . ~/.deepapi/env
KEY=$DEEPAPI_API_KEY
BASE=${DEEPAPI_API_BASE_URL:-https://deepapi.co}- Key missing → stop and ask the user. Never print or log the key.
- 从环境变量中读取;配置时会将其写入
DEEPAPI_API_KEY。~/.deepapi/env - 注意事项: 请勿执行——这会导致shell崩溃(退出码126)。如果已设置环境变量则使用它,否则加载平台文件:
source ~/.zshrc
bash
[ -n "$DEEPAPI_API_KEY" ] || . ~/.deepapi/env
KEY=$DEEPAPI_API_KEY
BASE=${DEEPAPI_API_BASE_URL:-https://deepapi.co}- 若密钥缺失→停止操作并询问用户。切勿打印或记录密钥。
Step 1 — Build the research prompt
步骤1 — 构建研究提示
Write ONE self-contained paragraph following the skill:
research-prompt- Lead with the single question + the decision/end use it informs.
- Embed all context — no back-and-forth needed.
- Number 3-6 inline sub-questions (1, 2, 3…). One mission per prompt.
- State include/avoid constraints; prefer primary sources; separate fact from inference.
Field limits: ≤ 4000 chars (the paragraph goes here), optional ≤ 8000, optional ≤ 2000. Do NOT pass or fields — the API rejects provider controls.
querycontextinstructionsmodelprovider遵循技能的要求,撰写一段独立完整的段落:
research-prompt- 以单个问题及其要支撑的决策/最终用途开头。
- 嵌入所有上下文信息——无需来回沟通。
- 列出3-6个内嵌子问题(1、2、3…)。每个提示对应一项任务。
- 说明包含/排除的约束条件;优先使用原始数据源;区分事实与推论。
字段限制:≤4000字符(段落内容放在此处),可选≤8000字符,可选≤2000字符。请勿传入或字段——API会拒绝提供商控制参数。
querycontextinstructionsmodelproviderStep 2 — Run it
步骤2 — 执行查询
One call = one cited answer (targets 700-1,120 words; the server allows up to ~5 minutes, most runs finish much faster).
bash
IDK=$(uuidgen) # keep this; retries must reuse the SAME Idempotency-Key
jq -n --rawfile p /tmp/dr_prompt.txt '{query:$p, maxCostUsd:"0.70"}' > /tmp/dr_body.json
curl -s --max-time 320 "$BASE/v1/research/deep" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $IDK" \
-d @/tmp/dr_body.json > /tmp/dr_result.jsonThe API minimum is per call. Use the recommended
by default; raise it above $0.70 only if the user approves.
maxCostUsd: "0.35"maxCostUsd: "0.70"一次调用会生成一个带引用的答案(目标字数700-1120字;服务器允许最长等待约5分钟,多数运行会快得多)。
bash
IDK=$(uuidgen) # 保留此值;重试时必须使用相同的Idempotency-Key
jq -n --rawfile p /tmp/dr_prompt.txt '{query:$p, maxCostUsd:"0.70"}' > /tmp/dr_body.json
curl -s --max-time 320 "$BASE/v1/research/deep" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $IDK" \
-d @/tmp/dr_body.json > /tmp/dr_result.jsonAPI的单次调用最低成本为。默认使用推荐的;仅在用户批准的情况下才将其提高到0.70美元以上。
maxCostUsd: "0.35"maxCostUsd: "0.70"Step 3 — Read the report + sources
步骤3 — 读取报告与数据源
bash
jq -r '.status' /tmp/dr_result.json # succeeded | failed
jq -r '.output.answer' /tmp/dr_result.json # the report
jq -r '.output.sources[]?.url' /tmp/dr_result.json # source URLsSave the report to a markdown file for the user and list citation URLs beneath it. Don't report research costs unless the user asks.
If comes back empty while the answer shows citation markers, still deliver the report, but tell the user.
output.sources[n]bash
jq -r '.status' /tmp/dr_result.json # succeeded | failed
jq -r '.output.answer' /tmp/dr_result.json # 报告内容
jq -r '.output.sources[]?.url' /tmp/dr_result.json # 数据源URL将报告保存为markdown文件提供给用户,并在下方列出引用URL。除非用户询问,否则无需告知研究成本。
若返回为空,但答案中显示引用标记,仍需交付报告,但要告知用户此情况。
output.sources[n]Bigger topics — multi-call reports
大型主题 — 多调用报告
One call tops out around 1,100 words. For a full deep-research report, fire one call per numbered sub-question (each with its own Idempotency-Key), then synthesize all answers + sources into a single markdown file.
单次调用的输出上限约为1100字。对于完整的深度研究报告,可为每个编号子问题发起一次调用(每个调用使用独立的Idempotency-Key),然后将所有答案和数据源整合为单个markdown文件。
Failure modes
失败场景
- HTTP 402 → stop; the user tops up at deepapi.co/credits; then retry with the SAME
insufficient_credits(safe — replays don't double-charge).Idempotency-Key - HTTP 429 → wait
rate_limit_exceededseconds, retry once.Retry-After - / HTTP 502 → report
status: failed+requestIdto the user. Do not retry in a loop.error.message - Replayed request (same Idempotency-Key) returns HTTP 200 with and no new charge.
replayed: true - Envelope/auth mechanics and all other endpoints: see the skill.
deepapi
- HTTP 402 →停止操作;用户需前往deepapi.co/credits充值;然后使用相同的
insufficient_credits重试(安全——重放不会重复扣费)。Idempotency-Key - HTTP 429 →等待
rate_limit_exceeded秒后重试一次。Retry-After - / HTTP 502→向用户报告
status: failed+requestId。请勿循环重试。error.message - 重放请求(使用相同的Idempotency-Key)会返回HTTP 200,且,不会产生新费用。
replayed: true - 信封/认证机制及所有其他端点:请查看技能。
deepapi