Adding sky in Python API
Try this:
import bpy

sky_texture = bpy.context.scene.world.node_tree.nodes.new(&quot;ShaderNodeTexSky&quot;)
bg = bpy.context.scene.world.node_tree.nodes[&quot;Background&quot;]
bpy.context.scene.world.node_tree.links.new(bg.inputs[&quot;Color&quot;], sky_texture.outputs[&quot;Color&quot;])

You can then tweak the options like this:
sky_texture.sky_type = 'HOSEK_WILKIE' # or 'PREETHAM'
sky_texture.turbidity = 2.0
sky_texture.ground_albedo = 0.4
sky_texture.sun_direction = mathutils.Vector((1.0, 0.0, 1.0))  # add `import mathutils` at the beginning of the script