wp_download_url() for dynamically generated image

Without more information, it’s hard to tell what the reason is, for a specific answer you might want to show your code.

The following uploads the lady to the media library:

$url="https://res.cloudinary.com/demo/image/upload/w_400,h_400,c_crop,g_face,r_max/w_200/lady.jpg";
// $post_id = 0 to not attach to specific post
media_sideload_image( $url, 0 );

If you’re outside /wp-admin, you’ll need:

require_once(ABSPATH . 'wp-admin/includes/media.php');
require_once(ABSPATH . 'wp-admin/includes/file.php');
require_once(ABSPATH . 'wp-admin/includes/image.php');

Consult the documentation for further information: