Skip to main content
post/knowledge-fs/spaces/{knowledge_base_id}/research-tasks
Request example
Response
post/knowledge-fs/spaces/{knowledge_base_id}/research-tasks

Authorization

Authorizationstringheaderrequired#

Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).

Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).

Path parameters

knowledge_base_idstringrequired#
Knowledge base ID: the last segment of the Service API endpoint shown in the knowledge base's API Access dialog (…/knowledge-fs/spaces/<knowledge base ID>), and the segment after /datasets/new/ in the address bar.

Headers

Idempotency-Keystring#

Optional key that makes creation safe to retry. Use 8 to 255 printable ASCII characters without leading or trailing whitespace; a malformed key answers 400.

Repeating the same key and body with the same API key returns the original task, in its current state, with 202 instead of creating another. Keys are unique within the workspace: reusing a key with a different body, from another API key, in another knowledge base, or for another operation answers 409.

Length: 8–255

Body

application/json
budgetUsdnumber#

Spend ceiling in USD. Enforced while the task runs, not at creation. The task is accepted even when the Plan Research Task estimate exceeds it. Before each model call, the task checks the call's worst-case cost against the budget, and it is canceled instead of making a call that could pass the budget.

A call can still cost more than its worst-case estimate, so cost.totalUsd can end above budgetUsd. A budget cancellation before the generating stage leaves the task with no answer. Worst-case costs usually run well above the plan's estimates, so when you need an answer, set the ceiling well above estimates.costUsd.max, and higher still for a large topK.

A task stopped by its budget ends in stage canceled.

Range: >= 0

limitsobject#

Checked once, at creation, against the plan's estimates. A task whose estimates exceed a limit is rejected with 422. Omitting limits skips these checks. Use budgetUsd to bound spending while the task runs.

An estimate equal to its limit passes. Size these against the estimates from Plan Research Task.

metadataobject#

Free-form object stored with the task and returned as metadata. Keys that start with __knowledgeFs are reserved and dropped.

Include a unique value such as client_request_id to recognize the task if the creation response is lost. This helps you find the task. To make a retry return the original task instead of creating another, send Idempotency-Key.

modeenum<string>#
Retrieval depth: fast, deep, or research (see Retrieval Depth). Omit it to use the knowledge base's default depth, retrieval.default_mode in Get Knowledge Base Settings.
Options:fastdeepresearchnull
querystringrequired#
The question. Use a nonblank query. Also limited to 16,384 UTF-8 bytes.

Length: max 16000Pattern: \S

topKinteger#
Maximum number of chunks kept after the search results are merged and reranked. Explicit values must be between 1 and 50. If omitted, uses the knowledge base's published TOP K setting, which can be up to 100. Higher values give the model more context and more noise. Lower values stay focused and can miss relevant chunks.

Range: 1–50

Responses

application/json
The task was accepted. stage is queued, mode is the resolved depth, and cost.totalUsd is 0. A repeat with the same Idempotency-Key and body returns the original task in its current state.
budget_usdnumber#
Spend ceiling from the request in USD. null when none was set.
completed_atnumber#
When the task reached completed, failed, or canceled, in epoch milliseconds. null while the task is running.
costobject#
Spend recorded so far.
created_atnumber#
Epoch milliseconds when the task was created.
errorstring#

Failure code, the same value as failure.code. Present only when stage is failed, and null otherwise, including for canceled tasks.

On a failed research task, failure.code is one of RESEARCH_TASK_CAPABILITY_REVOKED, RESEARCH_TASK_DISPATCH_DEAD, RESEARCH_TASK_EXECUTION_ATTEMPTS_EXHAUSTED, RESEARCH_TASK_FAILED, RESEARCH_TASK_PERMISSION_SNAPSHOT_INVALID, or RESEARCH_TASK_RUNTIME_SNAPSHOT_INVALID.

failureobject#

Error details. Present only when stage is failed, and null otherwise. Members without a value are null here. traceId is the task ID.

When action is retry, create a new task with Create Research Task.

idstring#
Research task ID. Use it as research_task_id in the task operations.
knowledge_space_idstring#
Internal ID of the knowledge base. Not the knowledge base ID in the path.
limitsobject#
Limits from the request, with snake_case keys. null when the request carried no limits. A member that was not sent is null. Convert the keys back to camelCase before sending them to Create Research Task again.
metadataobject#
The metadata object sent at creation, without keys that start with __knowledgeFs.
modestring#
Retrieval depth of the task: fast, deep, or research.
querystring#
The research question as stored.
query_imagesobject[]#
Images used in the original query. Omitted for text-only queries.
stagestring#

Where the task is in its lifecycle. Tasks move forward one stage at a time:

  • queued: accepted, waiting for a worker.
  • planning: resolving the retrieval plan.
  • retrieving: searching the knowledge base. A retrieval checkpoint may be written.
  • analyzing: reading and weighing the retrieved chunks.
  • generating: writing the answer. The final result is written during this stage.
  • completed: finished. Read its results with List Research Task Results.
  • failed: stopped with an error. See error and failure.
  • canceled: stopped by Cancel Research Task or by the budget.
  • paused: The task is paused. Check any failure details with the deployment operator, or cancel it.

completed, failed, and canceled are terminal.

top_kinteger#
Maximum number of chunks kept after the search results are merged and reranked: the request's topK, or the knowledge base's TOP K when omitted.
updated_atnumber#
Epoch milliseconds of the last update to the task record, including internal checkpoints and retry scheduling.