{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/parallel-ai/json-schema/parallel-ai-task-run-event-schema.json",
  "title": "TaskRunEvent",
  "description": "Event when a task run transitions to a non-active status.\n\nMay indicate completion, cancellation, or failure.",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/parallel-ai-tasks-api-openapi.yml#/components/schemas/TaskRunEvent",
  "properties": {
    "type": {
      "type": "string",
      "const": "task_run.state",
      "title": "Type",
      "description": "Event type; always 'task_run.state'."
    },
    "event_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Event ID",
      "description": "Cursor to resume the event stream. Always empty for non Task Group runs."
    },
    "input": {
      "anyOf": [
        {
          "$ref": "#/$defs/TaskRunInput"
        },
        {
          "type": "null"
        }
      ],
      "description": "Input to the run; included only if requested."
    },
    "run": {
      "$ref": "#/$defs/TaskRun",
      "description": "Task run object."
    },
    "output": {
      "anyOf": [
        {
          "oneOf": [
            {
              "$ref": "#/$defs/TaskRunTextOutput"
            },
            {
              "$ref": "#/$defs/TaskRunJsonOutput"
            }
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Output",
      "description": "Output from the run; included only if requested and if status == `completed`."
    }
  },
  "type": "object",
  "required": [
    "type",
    "event_id",
    "run"
  ],
  "$defs": {
    "AutoSchema": {
      "properties": {
        "type": {
          "type": "string",
          "const": "auto",
          "title": "Type",
          "description": "The type of schema being defined. Always `auto`.",
          "default": "auto"
        }
      },
      "type": "object",
      "title": "AutoSchema",
      "description": "Auto schema for a task input or output."
    },
    "Citation": {
      "description": "A citation for a task output.",
      "properties": {
        "title": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Title of the citation.",
          "title": "Title"
        },
        "url": {
          "description": "URL of the citation.",
          "title": "Url",
          "type": "string"
        },
        "excerpts": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Excerpts from the citation supporting the output. Only certain processors provide excerpts.",
          "title": "Excerpts"
        }
      },
      "required": [
        "url"
      ],
      "title": "Citation",
      "type": "object"
    },
    "Error": {
      "properties": {
        "ref_id": {
          "type": "string",
          "title": "Reference ID",
          "description": "Reference ID for the error."
        },
        "message": {
          "type": "string",
          "title": "Message",
          "description": "Human-readable message."
        },
        "detail": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Detail",
          "description": "Optional detail supporting the error."
        }
      },
      "type": "object",
      "required": [
        "ref_id",
        "message"
      ],
      "title": "Error",
      "description": "An error message."
    },
    "FieldBasis": {
      "description": "Citations and reasoning supporting one field of a task output.",
      "properties": {
        "field": {
          "description": "Name of the output field.",
          "title": "Field",
          "type": "string"
        },
        "citations": {
          "default": [],
          "description": "List of citations supporting the output field.",
          "items": {
            "$ref": "#/$defs/Citation"
          },
          "title": "Citations",
          "type": "array"
        },
        "reasoning": {
          "description": "Reasoning for the output field.",
          "title": "Reasoning",
          "type": "string"
        },
        "confidence": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Confidence level for the output field. Only certain processors provide confidence levels.",
          "title": "Confidence"
        }
      },
      "required": [
        "field",
        "reasoning"
      ],
      "title": "FieldBasis",
      "type": "object"
    },
    "JsonSchema": {
      "properties": {
        "json_schema": {
          "additionalProperties": true,
          "type": "object",
          "title": "Json Schema",
          "description": "A JSON Schema object. Only a subset of JSON Schema is supported."
        },
        "type": {
          "type": "string",
          "const": "json",
          "title": "Type",
          "description": "The type of schema being defined. Always `json`.",
          "default": "json"
        }
      },
      "type": "object",
      "required": [
        "json_schema"
      ],
      "title": "JsonSchema",
      "description": "JSON schema for a task input or output."
    },
    "McpServer": {
      "properties": {
        "type": {
          "type": "string",
          "const": "url",
          "title": "Type",
          "description": "Type of MCP server being configured. Always `url`.",
          "default": "url"
        },
        "url": {
          "type": "string",
          "title": "Url",
          "description": "URL of the MCP server."
        },
        "headers": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "string",
                "format": "password",
                "writeOnly": true
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Headers",
          "description": "Headers for the MCP server."
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "Name of the MCP server."
        },
        "allowed_tools": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Allowed Tools",
          "description": "List of allowed tools for the MCP server."
        }
      },
      "type": "object",
      "required": [
        "url",
        "name"
      ],
      "title": "McpServer",
      "description": "MCP server configuration."
    },
    "McpToolCall": {
      "properties": {
        "tool_call_id": {
          "type": "string",
          "title": "Tool Call ID",
          "description": "Identifier for the tool call."
        },
        "server_name": {
          "type": "string",
          "title": "Server Name",
          "description": "Name of the MCP server."
        },
        "tool_name": {
          "type": "string",
          "title": "Tool Name",
          "description": "Name of the tool being called."
        },
        "arguments": {
          "type": "string",
          "title": "Arguments",
          "description": "Arguments used to call the MCP tool."
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Content",
          "description": "Output received from the tool call, if successful."
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Error",
          "description": "Error message if the tool call failed."
        }
      },
      "type": "object",
      "required": [
        "tool_call_id",
        "server_name",
        "tool_name",
        "arguments"
      ],
      "title": "McpToolCall",
      "description": "Result of an MCP tool call."
    },
    "SourcePolicy": {
      "properties": {
        "include_domains": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Include Domains",
          "description": "List of domains to restrict the results to. If specified, only sources from these domains will be included. Accepts plain domains (e.g., example.com, subdomain.example.gov) or bare domain extension starting with a period (e.g., .gov, .edu, .co.uk). The combined number of domains in include_domains and exclude_domains cannot exceed 200."
        },
        "exclude_domains": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Exclude Domains",
          "description": "List of domains to exclude from results. If specified, sources from these domains will be excluded. Accepts plain domains (e.g., example.com, subdomain.example.gov) or bare domain extension starting with a period (e.g., .gov, .edu, .co.uk). The combined number of domains in include_domains and exclude_domains cannot exceed 200."
        },
        "after_date": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "After Date",
          "description": "Optional start date for filtering search results. Results will be limited to content published on or after this date. Provided as an RFC 3339 date string (YYYY-MM-DD)."
        }
      },
      "type": "object",
      "title": "SourcePolicy",
      "description": "Source policy for web search results.\n\nThis policy governs which sources are allowed/disallowed in results."
    },
    "TaskAdvancedSettings": {
      "properties": {
        "location": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Location",
          "description": "ISO 3166-1 alpha-2 country code for geo-targeted search results."
        }
      },
      "type": "object",
      "title": "TaskAdvancedSettings",
      "description": "Advanced search configuration for a task run."
    },
    "TaskRun": {
      "properties": {
        "run_id": {
          "type": "string",
          "title": "Run ID",
          "description": "ID of the task run."
        },
        "interaction_id": {
          "type": "string",
          "title": "Interaction ID",
          "description": "Identifier for this interaction. Pass this value as `previous_interaction_id` to reuse context for a future request."
        },
        "status": {
          "type": "string",
          "enum": [
            "queued",
            "action_required",
            "running",
            "completed",
            "failed",
            "cancelling",
            "cancelled"
          ],
          "title": "Status",
          "description": "Status of the run."
        },
        "is_active": {
          "type": "boolean",
          "title": "Is Active",
          "description": "Whether the run is currently active, i.e. status is one of {'cancelling', 'queued', 'running'}."
        },
        "warnings": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Warning"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Warnings",
          "description": "Warnings for the run, if any."
        },
        "error": {
          "anyOf": [
            {
              "$ref": "#/$defs/Error"
            },
            {
              "type": "null"
            }
          ],
          "description": "Error for the run, present only if status is 'failed'."
        },
        "processor": {
          "type": "string",
          "title": "Processor",
          "description": "Processor used for the run."
        },
        "metadata": {
          "anyOf": [
            {
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "integer"
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Metadata",
          "description": "User-provided metadata stored with the run."
        },
        "taskgroup_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Taskgroup ID",
          "description": "ID of the taskgroup to which the run belongs."
        },
        "created_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Created At",
          "description": "Timestamp of the creation of the task, as an RFC 3339 string."
        },
        "modified_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Modified At",
          "description": "Timestamp of the last modification to the task, as an RFC 3339 string."
        }
      },
      "type": "object",
      "required": [
        "run_id",
        "interaction_id",
        "status",
        "is_active",
        "processor",
        "created_at",
        "modified_at"
      ],
      "title": "TaskRun",
      "description": "Status of a task run."
    },
    "TaskRunInput": {
      "properties": {
        "processor": {
          "type": "string",
          "title": "Processor",
          "description": "Processor to use for the task."
        },
        "metadata": {
          "anyOf": [
            {
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "integer"
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Metadata",
          "description": "User-provided metadata stored with the run. Keys and values must be strings with a maximum length of 16 and 512 characters respectively."
        },
        "memory_scope_key": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 128,
              "minLength": 1,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            {
              "type": "null"
            }
          ],
          "title": "Memory Scope Key",
          "description": "User-provided key identifying the memory scope to use. Omit to use personal memory, if available."
        },
        "source_policy": {
          "anyOf": [
            {
              "$ref": "#/$defs/SourcePolicy"
            },
            {
              "type": "null"
            }
          ],
          "description": "Optional source policy governing preferred and disallowed domains in web search results."
        },
        "advanced_settings": {
          "anyOf": [
            {
              "$ref": "#/$defs/TaskAdvancedSettings"
            },
            {
              "type": "null"
            }
          ],
          "description": "Advanced search configuration for the task run."
        },
        "task_spec": {
          "anyOf": [
            {
              "$ref": "#/$defs/TaskSpec"
            },
            {
              "type": "null"
            }
          ],
          "description": "Task specification. If unspecified, defaults to auto output schema."
        },
        "input": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "additionalProperties": true,
              "type": "object"
            }
          ],
          "title": "Input",
          "description": "Input to the task, either text or a JSON object."
        },
        "previous_interaction_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Previous Interaction Id",
          "description": "Interaction ID to use as context for this request."
        },
        "mcp_servers": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/McpServer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Mcp Servers",
          "description": "Optional list of MCP servers to use for the run."
        },
        "enable_events": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Enable Events",
          "description": "Controls tracking of task run execution progress. When set to true, progress events are recorded and can be accessed via the [Task Run events](https://docs.parallel.ai/api-reference) endpoint. When false, no progress events are tracked. Note that progress tracking cannot be enabled after a run has been created. The flag is set to true by default for premium processors (pro and above)."
        },
        "webhook": {
          "anyOf": [
            {
              "$ref": "#/$defs/Webhook"
            },
            {
              "type": "null"
            }
          ],
          "description": "Callback URL (webhook endpoint) that will receive an HTTP POST when the run completes. \nThis feature is not available via the Python SDK."
        }
      },
      "type": "object",
      "required": [
        "processor",
        "input"
      ],
      "title": "TaskRunInput",
      "description": "Request to run a task."
    },
    "TaskRunJsonOutput": {
      "properties": {
        "basis": {
          "items": {
            "$ref": "#/$defs/FieldBasis"
          },
          "type": "array",
          "title": "Basis",
          "description": "Basis for each top-level field in the JSON output. Per-list-element basis entries are available only when the `parallel-beta: field-basis-2025-11-25` header is supplied."
        },
        "type": {
          "type": "string",
          "const": "json",
          "title": "Type",
          "description": "The type of output being returned, as determined by the output schema of the task spec."
        },
        "mcp_tool_calls": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/McpToolCall"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Mcp Tool Calls",
          "description": "MCP tool calls made by the task."
        },
        "beta_fields": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Beta Fields",
          "description": "Deprecated. mcp-server-2025-07-17 is now included directly in the output (e.g. mcp_tool_calls).",
          "deprecated": true
        },
        "content": {
          "additionalProperties": true,
          "type": "object",
          "title": "Content",
          "description": "Output from the task as a native JSON object, as determined by the output schema of the task spec."
        },
        "output_schema": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Output Schema",
          "description": "Output schema for the Task Run. Populated only if the task was executed with an auto schema."
        }
      },
      "type": "object",
      "required": [
        "basis",
        "type",
        "content"
      ],
      "title": "TaskRunJsonOutput",
      "description": "Output from a task that returns JSON."
    },
    "TaskRunTextOutput": {
      "properties": {
        "basis": {
          "items": {
            "$ref": "#/$defs/FieldBasis"
          },
          "type": "array",
          "title": "Basis",
          "description": "Basis for the output. The basis has a single field 'output'."
        },
        "type": {
          "type": "string",
          "const": "text",
          "title": "Type",
          "description": "The type of output being returned, as determined by the output schema of the task spec."
        },
        "mcp_tool_calls": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/McpToolCall"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Mcp Tool Calls",
          "description": "MCP tool calls made by the task."
        },
        "beta_fields": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Beta Fields",
          "description": "Deprecated. mcp-server-2025-07-17 is now included directly in the output (e.g. mcp_tool_calls).",
          "deprecated": true
        },
        "content": {
          "type": "string",
          "title": "Content",
          "description": "Text output from the task."
        }
      },
      "type": "object",
      "required": [
        "basis",
        "type",
        "content"
      ],
      "title": "TaskRunTextOutput",
      "description": "Output from a task that returns text."
    },
    "TaskSpec": {
      "properties": {
        "output_schema": {
          "anyOf": [
            {
              "$ref": "#/$defs/JsonSchema"
            },
            {
              "$ref": "#/$defs/TextSchema"
            },
            {
              "$ref": "#/$defs/AutoSchema"
            },
            {
              "type": "string"
            }
          ],
          "title": "Output Schema",
          "description": "JSON schema or text fully describing the desired output from the task. Descriptions of output fields will determine the form and content of the response. A bare string is equivalent to a text schema with the same description."
        },
        "input_schema": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/JsonSchema"
            },
            {
              "$ref": "#/$defs/TextSchema"
            },
            {
              "type": "null"
            }
          ],
          "title": "Input Schema",
          "description": "Optional JSON schema or text description of expected input to the task. A bare string is equivalent to a text schema with the same description."
        }
      },
      "type": "object",
      "required": [
        "output_schema"
      ],
      "title": "TaskSpec",
      "description": "Specification for a task.\n\nAuto output schemas can be specified by setting `output_schema={\"type\":\"auto\"}`. Not\nspecifying a TaskSpec is the same as setting an auto output schema.\n\nFor convenience bare strings are also accepted as input or output schemas."
    },
    "TextSchema": {
      "properties": {
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description",
          "description": "A text description of the desired output from the task."
        },
        "type": {
          "type": "string",
          "const": "text",
          "title": "Type",
          "description": "The type of schema being defined. Always `text`.",
          "default": "text"
        }
      },
      "type": "object",
      "title": "TextSchema",
      "description": "Text description for a task input or output."
    },
    "Warning": {
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "spec_validation_warning",
            "input_validation_warning",
            "warning"
          ],
          "title": "Type",
          "description": "Type of warning. Note that adding new warning types is considered a backward-compatible change."
        },
        "message": {
          "type": "string",
          "title": "Message",
          "description": "Human-readable message."
        },
        "detail": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Detail",
          "description": "Optional detail supporting the warning."
        }
      },
      "type": "object",
      "required": [
        "type",
        "message"
      ],
      "title": "Warning",
      "description": "Human-readable message for a task."
    },
    "Webhook": {
      "properties": {
        "url": {
          "type": "string",
          "title": "Url",
          "description": "URL for the webhook."
        },
        "event_types": {
          "items": {
            "type": "string",
            "enum": [
              "task_run.status"
            ]
          },
          "type": "array",
          "title": "Event Types",
          "description": "Event types to send the webhook notifications for.",
          "default": []
        }
      },
      "type": "object",
      "required": [
        "url"
      ],
      "title": "Webhook",
      "description": "Webhooks for Task Runs."
    }
  }
}