Using a community plugin within a custom gradle plugin

I’m building a plugin in kotlin that will be published to a Maven Repo. Is there a way that I can use a community plugin and configure it within my new plugin? To configure the community plugin within a build.gradle file I would do this:

 openApiGenerate {
      // Config code here
 }

I would like to be able to do this with my plugin task.

Currently, I have classes that implement Plugin and DefaultTask().

MyPluginTask.kt

abstract class MyPluginTask : DefaultTask() {
    @TaskAction
    fun myPluginTask() {
         // Would like to put code here to configure the community plugin
    }

MyPlugin.kt

open class MyPlugin : Plugin<Project> {
    override fun apply(project: Project) {
        project.pluginManager.apply(BasePlugin::class.java)
        val myTask = project.tasks.register("myTask", MyPluginTask::class.java) {
			this.description = "This is the main task for this plugin"
			this.group = BasePlugin.BUILD_GROUP
        }
    }
}