Get started
Quickstart
From key to first result in a few minutes. This example creates an image task and polls until it is ready.
javascript
const KEY = process.env.YOUBOT_API_KEY;
// 1) create a task
const create = await fetch("https://you.bot/api/v1/generate", {
method: "POST",
headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
modelId: "nano-banana-pro",
input: { prompt: "a corgi astronaut, studio lighting" },
}),
});
const { taskId, creditsCharged } = await create.json();
console.log("charged", creditsCharged, "credits");
// 2) poll until it finishes (pass ?model= so we can resolve the result)
let task;
do {
await new Promise((r) => setTimeout(r, 2000));
task = await fetch(`https://you.bot/api/v1/task/${taskId}?model=nano-banana-pro`, {
headers: { Authorization: `Bearer ${KEY}` },
}).then((r) => r.json());
} while (task.state === "waiting" || task.state === "generating");
// 3) read the result
if (task.state === "success") console.log(task.resultUrls);
else console.error("failed:", task.error);Chat/LLM models skip the polling step — they return { text, creditsCharged } directly from the create call.