I get on error 400 bad request in generate image in open ai <why?

const inp = document.getElementById(‘inp’);
const images = document.querySelector(‘.images’);

const getImage = async () =>{
const methods={
method:“POST”,
headers:{
“Content-Type”: “application/json”,
“Authorization”:Bearer ${api}
},
body:JSON.stringify(
{
“model”: “dall-e-3”,
“prompt”:inp.value,
“n”:3,
“size”:“1024x1024”
}
)}
const res = await fetch(“here i put url”,methods);
const data = await res.json();
console.log(data);

}

Document

AI images generator

</div>
<div class="prompt">
    <input id="inp" type="text">
    <button onclick="getImage()">generate</button>
</div>
<script src="scripts.js"></script>

With a 5-second scan, the first error:

  • DALL-E 3 only generates one image per API call. n=3 is invalid.