How do I add a medium to the WordPress database with my own plugin?

After a long search, I finally found the error. It is necessary to use

require "/path/to/wordpress/wp-load.php";

to enable wordpress functions in scripts.