Read API value from via Kotlin DSL

I am saving my apiKey on my in my manifest I need to pass a value for the meta-data which is the apiKey and i am trying to use value = ${myApiKey}" how do I access the in the build.gradle.kts and use my {myApiKey} in my manifest. This is similar to what I want to achieve but I am wondering where do I put

 buildConfigField("String", "API_KEY", getApiKey())

considering I have different build variants.