API Key implementation shows 401 (Unauthorized) image to text api

const API_KEY = “my_api_key_here”;
const submit = document.querySelector(“#submit_btn”);
const inputPrompt = document.querySelector(“#prompt_user”);
const getImages = async() => {
const options = {
method: “POST”,
header: {
“Authorization”: Bearer ${API_KEY},
“Content-Type”: “application/json”
},
body: JSON.stringify({
“prompt”: inputPrompt.value,
“n”: 2,
“size”: “1024x1024”
})
}
try {
const response = await fetch(‘api key generation link’, options)
const data = await response.json();
console.log(data)
} catch (error) {
console.error(error)
}
console.log(options)
}

    submit.addEventListener("click", function(e) {
        getImages();
        e.preventDefault();
    })

How can i get the text to image output it shows 401 unauthorized

You should get the full response to see the error.

Check your model list by API or on the rate limit page, the access to the vision model has been changing.