result = {
yield "loading"
yield fetch(`https://api.stability.ai/v1beta/generation/${engine}/text-to-image`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-type': 'application/json',
'Accept': "application/json",
},
body: JSON.stringify(payload),
signal: toSignal(invalidation)
})
.then(response => {
if(response.status !== 200) {
return response.text()
}
return response.json()
})
}