Skip to main content
POST
Create Research Task

Authorizations

Authorization
string
header
required

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).

Headers

Idempotency-Key
string

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.

Required string length: 8 - 255

Path Parameters

knowledge_base_id
string<uuid>
required

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.

Body

application/json

Optional fields marked nullable treat null as omitted.

The normalized request must fit within 65,536 UTF-8 bytes. See Request Size Limits.

Provide a nonblank query.

query
string
required

The question. Use a nonblank query. Also limited to 16,384 UTF-8 bytes.

Maximum string length: 16000
Pattern: \S
budgetUsd
number | null

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.

Required range: x >= 0
limits
object | null

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.

metadata
object

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.

mode
enum<string> | null

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.

Available options:
fast,
deep,
research,
null
topK
integer | null

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.

Required range: 1 <= x <= 50

Response

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_usd
number | null

Spend ceiling from the request in USD. null when none was set.

completed_at
number | null

When the task reached completed, failed, or canceled, in epoch milliseconds. null while the task is running.

cost
object

Spend recorded so far.

created_at
number

Epoch milliseconds when the task was created.

error
string | null

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.

failure
object | null

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.

id
string

Research task ID. Use it as research_task_id in the task operations.

knowledge_space_id
string

Internal ID of the knowledge base. Not the knowledge base ID in the path.

limits
object | null

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.

metadata
object

The metadata object sent at creation, without keys that start with __knowledgeFs.

mode
string | null

Retrieval depth of the task: fast, deep, or research.

query
string

The research question as stored.

query_images
object[]

Images used in the original query. Omitted for text-only queries.

stage
string

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_k
integer | null

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_at
number

Epoch milliseconds of the last update to the task record, including internal checkpoints and retry scheduling.