kirha logo

Tasks

What is a task

A task is an asynchronous, deep research job. Unlike kirha.search() which returns results synchronously from a single vertical, a task searches across multiple verticals, validates findings with multiple agents, and can retry failed steps automatically. This produces more thorough, more accurate answers at the cost of more time and credits.

search gives you a fast answer from a single vertical. task is a full research pipeline that gathers data, cross-checks it, and reports back.

SearchTask
ResponseSynchronousAsynchronous (polling)
Vertical scopeSingle verticalMulti-vertical
Depth of answerQuick, surface-levelDeep, comprehensive
ValidationNoneMulti-agent validation
Retries on failureNoAutomatic retries
Credit usageLowerHigher
Best forSimple lookups, real-time dataComplex research, cross-domain analysis

Task lifecycle

StatusDescription
QueuedTask is waiting to be processed
ResearchingGathering data across multiple verticals and providers
ValidatingMultiple agents cross-check and validate the results. May retry the research step if needed
SummarizingFinal result is being generated from validated data
CompletedTask finished successfully, result is available
FailedTask failed, error is available

Create a task

Use kirha.task(query, options?) to create a task.

import { Kirha } from "kirha";

const kirha = new Kirha({
  apiKey: process.env.KIRHA_API_KEY,
});

const task = await kirha.task( 
  "Compare the AI strategies of Google, Microsoft, and Meta: key acquisitions, patent filings, and recent product launches", 
  { instruction: "Focus on 2024-2025 developments" } 
); 
console.log("Task created:", task.id); 

Credit usage

Tasks consume more credits than regular searches because they query multiple verticals and run multi-agent validation. You can track usage on the Dashboard.

Wait for completion

Call task.wait() to poll the task until it completes, fails, or times out.

import { Kirha, TaskStatus } from "kirha";

const kirha = new Kirha({
  apiKey: process.env.KIRHA_API_KEY,
});

const task = await kirha.task(
  "Compare the AI strategies of Google, Microsoft, and Meta",
  { instruction: "Focus on 2024-2025 developments" }
);

const result = await task.wait(); 
if (result.status === TaskStatus.Completed) { 
  console.log("Result:", result.result); 
} else { 
  console.log("Error:", result.error); 
} 

Check status manually

You can check the task status or fetch the result without waiting:

const status = await task.status(); 
console.log(status.status); // "Queued" | "Researching" | ...

const result = await task.result(); 
console.log(result.result); 

Status getters

The Task instance exposes getters to check the current cached status without making an API call:

task.isCompleted  // true if status is "Completed"
task.isFailed     // true if status is "Failed"
task.isPending    // true if status is "Queued", "Researching", "Validating", or "Summarizing"
task.isQueued     // true if status is "Queued"
task.isResearching // true if status is "Researching"
task.isValidating  // true if status is "Validating"
task.isSummarizing // true if status is "Summarizing"

Task options

Prop

Type

Wait options

Prop

Type

On this page