How to add keyframes and change the shape key (named shrinkwrap) value with Python?
Your &quot;shrinkwrap&quot; is a shape key.
You have to access it through the object data, in the shape_keys part and get the key_block by its name (or index).
That can be:
import bpy


#Get the object
lightsaber = bpy.data.objects['Lightsaber']

#Get the shape key
shrinkwrap = lightsaber.data.shape_keys.key_blocks['Shrinkwrap']

#Assign values and insert keyframes on it

shrinkwrap.value = 1
shrinkwrap.keyframe_insert(&quot;value&quot;, frame = 0)

shrinkwrap.value = 0
shrinkwrap.keyframe_insert(&quot;value&quot;, frame = 50)