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 initiated workflow execution:

  • success (bool): Indicates if the workflow execution was successfully initiated.
  • message (str): A message confirming the execution creation.
  • workflow_version_execution_id (int): Unique identifier for the workflow execution.

Example response:

{
    'message': 'Workflow execution created successfully',
    'success': True,
    'workflow_version_execution_id': 115
}

Important Note

This method only initiates the workflow execution. The actual workflow may take time to complete. To retrieve the results once the workflow has finished, you need to use a separate API endpoint. For details on how to fetch the workflow execution results, including the required parameters and response format, please refer to the Get Workflow Version Execution Results API documentation.

Advanced Usage

Using Input Variables

Adding Metadata

Using Workflow Labels