Insert keyframe through python and set its properties
Found a solution using this related thread https://blender.stackexchange.com/a/32540/31246 and this How do I add keyframes to a newly created action with no associated objects? (thanks @batFinger)
Here is the resulting code where i already have a bunch of variable (frame, value, data_path, array_index, handle_left_type) :
# parent is the object/node_tree ... containing the animation_data
# get_unique_name is(collection, base_name) is a function to ensure name is not used,
# and if so iterate by adding numbers

# find fcurve
if parent.animation_data is None:
    parent.animation_data_create()
a_d = parent.animation_data

if a_d.action is None:
    new_name = get_unique_name(bpy.data.actions, parent.name + &quot;Action&quot;)
    a_d.action = bpy.data.actions.new(new_name)

fc = a_d.action.fcurves.find(data_path, index = array_index)
if fc is None:
    fc = a_d.action.fcurves.new(data_path, index = array_index, action_group = group_name)

new_key = fc.keyframe_points.insert(
        frame,
        value
        )
new_key.handle_left_type = old_handle_left_type

Cheers !