Using Python to add an HDRI to world node
Similar to How to load an image from disc and assign it to a newly created image texture node? use BlendDataImages.load() to load and assign the image to the Environment Texture node:

import bpy

C = bpy.context
scn = C.scene

# Get the environment node tree of the current scene
node_tree = scn.world.node_tree
tree_nodes = node_tree.nodes

# Clear all nodes
tree_nodes.clear()

# Add Background node
node_background = tree_nodes.new(type='ShaderNodeBackground')

# Add Environment Texture node
node_environment = tree_nodes.new('ShaderNodeTexEnvironment')
# Load and assign the image to the node property
node_environment.image = bpy.data.images.load(&quot;//hdri.exr&quot;) # Relative path
node_environment.location = -300,0

# Add Output node
node_output = tree_nodes.new(type='ShaderNodeOutputWorld')   
node_output.location = 200,0

# Link all nodes
links = node_tree.links
link = links.new(node_environment.outputs[&quot;Color&quot;], node_background.inputs[&quot;Color&quot;])
link = links.new(node_background.outputs[&quot;Background&quot;], node_output.inputs[&quot;Surface&quot;])

Related: Control Cycles material nodes and material properties