How do I make objects in my bpy script have transparent materials?
This sets up a Principled BSDF using the transmission input for transparency. It also throws all the renderer switches for Eevee to show the transparency.
import bpy

name=&quot;MyMaterial&quot;
overwrite=True

if(overwrite is True) and ( name in bpy.data.materials ):
    blenderMat = bpy.data.materials[name]

else:
    blenderMat = bpy.data.materials.new(name)
    name = blenderMat.name

    # get the nodes
blenderMat.use_nodes=True
nodes = blenderMat.node_tree.nodes
    # clear all nodes to start clean
for node in nodes:
    nodes.remove(node)
    # link nodes
links = blenderMat.node_tree.links

    #create the basic material nodes
node_output  = nodes.new(type='ShaderNodeOutputMaterial')
node_output.location = 400,0
node_pbsdf    = nodes.new(type='ShaderNodeBsdfPrincipled')
node_pbsdf.location = 0,0
node_pbsdf.inputs['Base Color'].default_value = (0.8, 0.05, 0.05, 1.0)
node_pbsdf.inputs['Alpha'].default_value = 1 # 1 is opaque, 0 is invisible
node_pbsdf.inputs['Roughness'].default_value = 0.2
node_pbsdf.inputs['Specular'].default_value = 0.5
node_pbsdf.inputs['Transmission'].default_value = 0.5 # 1 is fully transparent

link = links.new(node_pbsdf.outputs['BSDF'], node_output.inputs['Surface'])

blenderMat.blend_method = 'HASHED'
blenderMat.shadow_method = 'HASHED'
blenderMat.use_screen_refraction = True

bpy.context.scene.eevee.use_ssr = True
bpy.context.scene.eevee.use_ssr_refraction = True