Blender scripting: How to change texture color
Thanks brockmann, I figured it out from your links.
mat = bpy.data.materials.new(name=&quot;Material&quot;)
mat.use_nodes = True
bsdf = mat.node_tree.nodes[&quot;Principled BSDF&quot;]
color_ramp = mat.node_tree.nodes.new(&quot;ShaderNodeValToRGB&quot;)
color_ramp.color_ramp.elements[0].color = (0.2,0.8,0.7,1)
mat.node_tree.links.new(bsdf.inputs['Base Color'], color_ramp.outputs['Color'])
texImage = mat.node_tree.nodes.new('ShaderNodeTexImage')
texImage.image = bpy.data.images.load(&quot;../textures/Fabric.png&quot;)
mat.node_tree.links.new(color_ramp.inputs[0], texImage.outputs['Color'])

ob = bpy.data.objects['model']
if ob.data.materials:
    ob.data.materials[0] = mat
else:
    ob.data.materials.append(mat)
```