In the Task API, we define three core components: Task, Run, and Runner.

Defining Task Components

Tasks

A task is a reusable template for web research and analysis. Think of it like a function that takes structured inputs and returns structured outputs and executes web research operations in between. Each Task requires the following components:

ComponentDefinition
NameIdentifier for the Task
Task SpecNatural language instructions defining what to research and analyze
Input SchemaDefinition of required input parameters
Output SchemaStructure of the expected results
ProcessorChosen Parallel processor that will execute the research

Task Specification

Instructions written in natural language and can include:

  • Research objectives

  • Analysis instructions

  • Source requirements

  • Validation criteria

  • Output formatting

It can be hyper-specific to your use case. Think of the task specification as the instructions you would provide a competent research analyst with. Variables in the Task Spec are marked with curly braces (e.g., find the population of {state}, identify the name of the CEO for {company}) and are replaced with input values when the task runs.

Input and Output Schema

Tasks can take various types of inputs and outputs. Inputs can be required or optional, allowing for flexibility across Task runs. The Input schema corresponds to the input variables included as part of the Task Spec. It can be adapted to your use case. For example, in a company research use case, {company_name} and {company_website} may both be required inputs:

input_schema = {
    "properties": {
        "company_name": {
            "type": "string",
            "description": "Company name"
        }
        "company_website": {
            "type": "string",
            "description": "Company website URL"
        }
    },
    "required": ["company_name", "company_website"]
}

Below is an example of a complex output with structured data that illustrates the flexibility of the schema:

{
    "properties": {
        "metrics": {
            "type": "object",
            "properties": {
                "market_share": {"type": "number"},
                "growth_rate": {"type": "number"},
                "competitor_count": {"type": "integer"}
            }
        },
        "trends": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {"type": "string"},
                    "impact": {"type": "string"},
                }
            }
        }
    }
}

Processors

ComponentDescription
TaskThe specification of your web research task
RunAn individual execution of your Task
RunnerThe engine that executes your Task

A single Task can have multiple Runs. For example, you may want to run the same Task on thousands of sets of inputs. At each execution, you can specify a Runner. The Runner you choose will determine complexity and cost of outputs.

You can learn more about each of the core components in our Docs.