QwQ AI / API v1

API 接入文档

把 QwQ AI 的联网问答、深度研究和金融研究接入你的应用。使用账户余额,价格与网页完全一致。

快速开始

登录后在个人中心创建 API Key,并充值余额。请求使用 Authorization: Bearer QWQ_API_KEY。在服务器环境变量中保存 Key。

export QWQ_API_KEY='qwq_your_key_here'

curl https://qwq32.com/api/v1/answer \
  -H "Authorization: Bearer $QWQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "What causes the aurora borealis?"
}'

接口根地址: https://qwq32.com/api/v1

可用接口

接口用途
POST /api/v1/answer快速联网回答,附带引用和搜索结果。
POST /api/v1/research五档深度的研究报告;支持来源控制和结构化 JSON。
POST /api/v1/finance_research金融研究与分析,支持 Deep 和 Exhaustive。
GET /api/v1/research/{task_id}领取后台研究结果;轮询免费,仅能访问自己的任务。

请求参数与示例

Answer

query 必填,非空且最多 400 字符。可选 freshness(day/week/month/year 或 YYYY-MM-DDtoYYYY-MM-DD)、country、language、safesearch,以及 include_domains / exclude_domains / boost_domains。每个域名列表最多 500 项;include_domains 不能与另外两个列表同时使用。country 和 language 需使用 You.com 支持的代码。

curl https://qwq32.com/api/v1/answer \
  -H "Authorization: Bearer $QWQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "Recent advances in renewable energy",
  "freshness": "month",
  "language": "EN",
  "safesearch": "moderate",
  "include_domains": [
    "energy.gov"
  ]
}'

Research

input 必填,非空且最多 40,000 字符。research_effort 支持 lite、standard(默认)、deep、exhaustive、frontier。source_control 可含域名列表、freshness 和 country,域名组合限制与 Answer 相同。background 可选。需要指定回答语言时,直接在 input 中说明。

curl https://qwq32.com/api/v1/research \
  -H "Authorization: Bearer $QWQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "Compare three battery technologies. Respond in Chinese.",
  "research_effort": "deep",
  "background": true,
  "source_control": {
    "freshness": "year",
    "exclude_domains": [
      "example.com"
    ]
  }
}'

可选 output_schema 使用 You.com 支持的 JSON Schema 子集,返回 output.content 对象;lite 不支持。根节点需为 object,每个对象设置 additionalProperties:false,所有属性列入 required。上游会校验结构、深度和属性数量限制,失败请求会退款。

Finance Research

input 必填,非空且最多 40,000 字符。research_effort 仅支持 deep(默认)和 exhaustive;Finance 为同步调用,最长需等待约 6 分钟。

curl https://qwq32.com/api/v1/finance_research \
  -H "Authorization: Bearer $QWQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "Analyze the latest NVIDIA earnings and cite sources.",
  "research_effort": "deep"
}'

未知参数被拒绝。请求体最多 180,000 字节。调用者不能指定用户、价格或上游 API Key。

同步响应

成功返回 HTTP 200,保留 Answer 的 answer、citations 和 results 字段,并增加 billing(本次费用、请求编号、扣款后余额)。金额为 USD;1 余额单位 = $0.0000001。

{
  "answer": "A cited answer [[1]]",
  "citations": [
    {
      "source": "https://example.com",
      "excerpts": [
        "Supporting evidence"
      ]
    }
  ],
  "results": {
    "web": []
  },
  "billing": {
    "request_id": "uuid",
    "cost_usd": 0.02,
    "cost_units": 200000,
    "balance_usd": 9.98
  }
}

Research 和 Finance 返回 output.content、output.content_type、output.sources,以及 billing。引用 [[1]] 对应来源列表的第 1 项。结构化 Research 的 output.content 为 JSON 对象。

后台研究与结果领取

Research 的 deep、exhaustive、frontier 自动使用后台模式,返回 HTTP 202。lite / standard 可通过 background:true 启用。保存 QwQ 返回的 task_id,并在 24 小时内领取结果。任务已扣一次费用,轮询不重复计费。

{
  "task_id": "qwq-task-uuid",
  "status": "queued",
  "expires_at": "2026-10-04T00:00:00.000Z",
  "billing": {
    "request_id": "qwq-task-uuid",
    "cost_usd": 0.3,
    "cost_units": 3000000,
    "balance_usd": 9.7
  }
}
curl https://qwq32.com/api/v1/research/QWQ_TASK_ID \
  -H "Authorization: Bearer $QWQ_API_KEY"

建议每 5–15 秒轮询一次。状态为 submitting、queued、running、completed 或 failed;completed 时读取 result.output。failed 附带 QUERY_FAILED_REFUNDED。任务属于账户,可使用该账户的任意有效 Key 领取。上游临时轮询失败可重试,不触发退款。

{
  "task_id": "qwq-task-uuid",
  "status": "completed",
  "expires_at": "2026-10-04T00:00:00.000Z",
  "result": {
    "output": {
      "content": "A researched report [[1]]",
      "content_type": "text",
      "sources": [
        {
          "url": "https://example.com",
          "title": "Source"
        }
      ]
    }
  }
}

服务端接入示例

JavaScript / Node.js

const response = await fetch("https://qwq32.com/api/v1/answer", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.QWQ_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ query: "What causes the aurora borealis?" }),
});
const data = await response.json();
if (!response.ok) throw new Error(data.code);
console.log(data.answer, data.billing.cost_usd);

Python / requests

import os
import requests

response = requests.post(
    "https://qwq32.com/api/v1/finance_research",
    headers={"Authorization": f"Bearer {os.environ['QWQ_API_KEY']}"},
    json={"input": "Analyze NVIDIA earnings", "research_effort": "deep"},
    timeout=370,
)
response.raise_for_status()
print(response.json()["output"]["content"])

按次计价

直接读取网站的统一费率配置。网页和 API 共享余额;执行前扣费,上游调用失败幂等退回,未完成的过期研究任务也会自动退款。最低充值 $10,无订阅。

工具 / 档位每次(USD)
answer$0.02
research / lite$0.04
research / standard$0.15
research / deep$0.30
research / exhaustive$1.35
research / frontier$3.60
finance / deep$0.35
finance / exhaustive$1.50
充值余额 →

错误处理

错误响应为 JSON,code 字段描述错误。

400 / 413
INVALID_REQUEST / QUERY_TOO_LONG:参数无效或请求体过大,不扣费。
401
INVALID_API_KEY:Key 缺失、错误或已撤销。
402
INSUFFICIENT_BALANCE:余额不足,不调用上游。
404 / 410
JOB_NOT_FOUND / JOB_EXPIRED:任务不存在、非本人任务或已过期。
502 / 503
QUERY_FAILED_REFUNDED:调用失败且已退款。JOB_POLL_FAILED:任务轮询临时失败,可重试。SERVICE_UNAVAILABLE / BILLING_UNAVAILABLE:服务暂不可用;计费状态可能尚未结算,请先查消费记录。

每次新的 POST 都视为新的付费查询,不支持查询幂等重放。网络超时或计费异常后先查看消费记录;已知任务编号时只重试 GET 轮询。

隐私与记录

Key 只保存 SHA-256 哈希,创建时显示一次,可随时撤销。API 消费页展示最近 100 次已扣费调用的工具、档位、费用、状态和 Key 名称。本站不保存问题、答案或报告正文;上游为后台任务临时保存结果,请及时领取并在自己的系统中保存。