Adding AI Image Generation to Your App
Submit an image-generation task, poll its status, and retrieve the output using the Orux AI API.
ai image generation api
Models available now
Browse full catalogWhat you'll build
Submit an image prompt as an asynchronous task, check its status, and read the generated result. The exact input fields depend on the model you select.
1. Choose a model and create an API key
Browse the live image model catalog, open a model's detail page, and follow its request schema. Create an API key from Keys.
2. Submit a task
const headers = {
Authorization: "Bearer " + process.env.ORUX_API_KEY,
"Content-Type": "application/json",
}
const response = await fetch("https://orux.top/api/v1/tasks", {
method: "POST",
headers,
body: JSON.stringify({
model: "YOUR_IMAGE_MODEL_ALIAS",
input: { prompt: "a red fox in a snowy forest, cinematic light" },
}),
})
if (!response.ok) throw new Error(await response.text())
const { task_id } = await response.json()Swipe horizontally to view the full content
Replace the model alias and input fields with values accepted by the model detail page.
3. Poll for the result
let task
do {
await new Promise((resolve) => setTimeout(resolve, 5000))
task = await fetch("https://orux.top/api/v1/tasks/" + task_id, { headers }).then((r) => r.json())
} while (task.status === "QUEUED" || task.status === "RUNNING")
if (task.status !== "SUCCESS") throw new Error(task.error?.message ?? task.status)
console.log(task.result)Swipe horizontally to view the full content
Failed or expired tasks are not charged. Check current model prices and each model's supported settings before submitting.
Common API responses
- HTTP 401 — check that the API key is present, valid, and sent as a Bearer token.
- HTTP 402 — the account balance is insufficient; review the balance page.
- HTTP 429 — slow down requests and retry with exponential backoff and jitter.
Next steps
Compare image models in the catalog, try a model in its detail page, and use the API quickstart to review authentication.