Draw curve by 2 points on mesh

Hi!
How I can draw curve by 2 points on 3d-mesh with minimal lenght?
Maybe need use

bpy.ops.curve.primitive_bezier_curve_add(radius=1.0, enter_editmode=False, align='WORLD', location=(0.0, 0.0, 0.0), rotation=(0.0, 0.0, 0.0), scale=(0.0, 0.0, 0.0))

But it’s use only one point

It is my solution:

def draw_curve_on_mesh_between_2_points(point_location_0, point_location_1, size=10):
    depsgraph = bpy.context.evaluated_depsgraph_get()    
    normal_0, index_polygon_0 = get_normal_and_index_polygon_smplx_model(point_location_0)
    normal_1, index_polygon_1 = get_normal_and_index_polygon_smplx_model(point_location_1)
    ray_from_point = [0, 0, 0]
    normal_average = [0, 0, 0]
    for i in range(3):
        ray_from_point[i] = point_location_1[i] - point_location_0[i]
        normal_average[i] = (normal_0[i] + normal_1[i]) / 2
    obj_human = get_human_obj()
    arr_points_on_mesh = [point_location_0]
    for i in range(size):
        point = [0, 0, 0]
        for j in range(3):
            point[j] = point_location_0[j] + ray_from_point[j] / size * (i + 1) 
        
        normal_point = [0, 0, 0]
        for i in range(3):
            normal_point[i] = normal_0[i] * (i+1 / size) + normal_1[i] * ((size - i -1)/size)
            
        result_point_on_mesh = get_point_on_mesh_using_ray(point, normal_point, depsgraph)
        #result_point_on_mesh = get_point_on_mesh_using_ray(point, normal_average, depsgraph)
        if result_point_on_mesh != None:
            if result_point_on_mesh[0]:
                arr_points_on_mesh.append(result_point_on_mesh[1])
    if len(arr_points_on_mesh):
        for i in range(1, len(arr_points_on_mesh)):
            point0 = arr_points_on_mesh[i - 1]
            point1 = arr_points_on_mesh[i]
            create_cylinder_between(point0[0], point0[1], point0[2], point1[0], point1[1], point1[2])    
            create_sphere(point1[0], point1[1], point1[2], r=radius_cylinder, for_cylinder=True)     
    
def get_point_on_mesh_using_ray(point, normal_average, depsgraph):
    result = bpy.context.scene.ray_cast(depsgraph=depsgraph, origin=point, direction=normal_average)
    new_point = result[1]
    if not result[0]:
        return None
    else:
        if text_mesh_human in result[4].name:
            return result
        else:
            result = get_point_on_mesh_using_ray(new_point, normal_average, depsgraph)
            return result