Catalogue work is repetitive and large: hundreds of products that each need a search title, a meta description and alt text for the photo. It rewards a model that is consistent and inexpensive more than one that thinks for a long time. This tutorial uses Gemini 4 Hydrogen, the least expensive of the four Gemini 4 models in IaGenify, with a JSON schema so every answer has the same shape.
Read the products
The products live in an IaGenify Cloud SQL database. The SDK runs one statement at a time and returns its rows.
import { IaGenify } from "iagenify";
const api = new IaGenify({ apiKey: process.env.IAGENIFY_API_KEY });
const db = (await api.storage.list()).find((storage) => storage.label === "Shop");
const { rows } = await db.run({
action: "execute",
sql: "SELECT id, name, description, category FROM products WHERE seo_title IS NULL LIMIT ?",
params: [200],
});Ask for a shape, not prose
A session created with a schema answers JSON that matches it. The descriptions inside the schema are read by the model, so that is where lengths and tone are settled. memory: false keeps each product independent of the previous ones.
const writer = await api.models.create({
model: "gemini-4-hydrogen",
memory: false,
settings: { temperature: 0.2, instructions: "You write e-commerce SEO in the product's own language." },
schema: {
type: "object",
properties: {
title: { type: "string", description: "Search title, 60 characters at most" },
description: { type: "string", description: "Meta description, 155 characters at most" },
alt: { type: "string", description: "Factual alt text for the main photo, 120 characters at most" },
},
required: ["title", "description", "alt"],
},
});Write it back
for (const product of rows) {
const { outputs } = await writer.generate({
inputs: [{ type: "text", content: JSON.stringify(product) }],
});
const seo = outputs[0].content;
await db.run({
action: "execute",
sql: "UPDATE products SET seo_title = ?, seo_description = ?, image_alt = ? WHERE id = ?",
params: [seo.title, seo.description, seo.alt, product.id],
});
}The model's text only ever travels as a bound parameter, never as part of the statement. Run the loop on a small batch first, read the results, then raise the limit.
What it costs
Hydrogen is billed 375 credits per million input tokens and 1,875 per million output tokens, and one credit is one US cent. Each call is rounded up to whole credits, so a short product costs about two credits and a batch of 200 about 400. api.catalogue() returns the current rates, so a script can estimate a batch before running it.
References
Frequently asked questions
Why a schema instead of asking for JSON in the prompt?
A schema is applied to the answer, so every product comes back with the same three fields, ready to write.
Does it work the same way in Python?
Yes. api.models.create(model=..., schema=...) and db.run(action="execute", sql=..., params=[...]) take the same shape.