The run_workflow() method initiates the execution of predefined workflows in PromptLayer, allowing you to start complex, multi-step sequences. For a comprehensive understanding of workflows, including their use cases, key concepts, and versioning, please refer to the Workflows documentation.

Basic Usage

Parameters

  • workflow_name / workflowName (str, required): The name of the workflow to run.
  • input_variables / inputVariables (Dict[str, Any], optional): Variables to be used in the workflow.
  • metadata (Dict[str, str], optional): Additional metadata for the workflow run.
  • workflow_label_name / workflowLabelName (str, optional): Label name for the workflow version.
  • workflow_version / workflowVersion (int, optional): Specific version number of the workflow to run.

Return Value

The method returns a dictionary (Python) or object (JavaScript) containing information about the workflow execution, and the response structure depends on the return_all_outputs parameter.

When return_all_outputs is False (default):

Data from the output node of the workflow execution:

  • status (str): The status of the workflow execution (e.g., "SUCCESS").
  • value (Any): The output produced by the output node.

Example response:

{
    'status': 'SUCCESS',
    'value': False
}

When return_all_outputs is True:

The method returns a dictionary containing detailed outputs from each node in the workflow execution:

  • Each key represents a node in the workflow (e.g., “Node 1”, “Node 2”).
  • Each node contains:
    • status (str): The execution status of the node (e.g., “SUCCESS”).
    • value (Any): The output value produced by the node.

Example response:

{
    'Node 1': {'status': 'SUCCESS', 'value': '123'},
    'Node 2': {'status': 'SUCCESS', 'value': '456'},
    'Node 3': {'status': 'SUCCESS', 'value': False}
}

Advanced Usage

Using Input Variables

Adding Metadata

Using Workflow Labels