TypeScript SDK
A small typed client with no dependencies. Works in Node 18+, Bun, Deno and edge runtimes.
npm install tovanoSet up
import Tovano from "tovano";
const tovano = new Tovano(); // reads TOVANO_API_KEY
// or: new Tovano({ apiKey: "tvn_live_...", baseUrl: "https://tovano.ai" })Run a task and wait
const task = await tovano.tasks.create({
model: "image/demo-1",
input: { prompt: "Blue ceramic mug, morning light", n: 4 },
customer: "client-0482",
});
const done = await tovano.tasks.wait(task.id, { timeoutMs: 120_000 });
if (done.status === "failed")
console.error(done.error.message); // not charged
else console.log(done.output.images, done.charged_micro);Chat
const reply = await tovano.chat.completions.create({
model: "text/demo-chat-1",
messages: [{ role: "user", content: "Three captions for a mug ad" }],
});
console.log(reply.choices[0].message.content);Balance and models
const { balance_micro } = await tovano.balance();
const models = await tovano.models.list();Verify a webhook
const ok = await tovano.webhooks.verify(
rawBody,
request.headers.get("tovano-signature"),
process.env.TOVANO_WEBHOOK_SECRET,
);Errors
Every failed call throws a TovanoError with status, code and message, the same as the error format.
try {
await tovano.tasks.create({ model: "image/demo-1", input: { prompt: "Mug" } });
} catch (err) {
if (err.code === "insufficient_credits") notifyBilling();
}