The NuGetApiKey is not marked mandatory on Publish-Module.
In point of fact, there are NuGet repositories, like the Visual Studio Online package repositories, which require credentials rather than API keys, so this error (with id "NuGetApiKeyIsRequiredForNuGetBasedGalleryService") is technically incorrect anyway.
You should just try the publish and provide proper errors when and if the authentication fails.