Beato Docs

TypeScript

Beato API client and runnable example for TypeScript.

Download the TypeScript SDK

Run the example

Extract the archive and run these commands inside its directory. The example lists public models by default. To submit a job, set BEATO_API_KEY and BEATO_IDEMPOTENCY_KEY in your environment.

npm install
npm run build
node example.mjs

Example source

import { setTimeout as sleep } from "node:timers/promises";
import { Beato } from "./dist/index.js";

const client = new Beato(process.env.BEATO_API_KEY, process.env.BEATO_API_BASE_URL);
const model = "nano-banana";
const idempotencyKey = process.env.BEATO_IDEMPOTENCY_KEY;
if (!idempotencyKey) console.log(await client.models());
else {
  let job = await client.createJob({ model, prompt: "A watercolor of a rainy street" }, idempotencyKey);
  for (let i = 0; i < 60 && !["succeeded", "failed"].includes(job.status); i++) {
    await sleep(5000);
    job = await client.getJob(job.id);
  }
  console.log(JSON.stringify(job));
}