import { KynvaClient } from "@kynva/sdk";
const kynva = new KynvaClient({ apiKey: process.env.KYNVA_API_KEY! });
// The brand you saved in step 2
const { data: brands } = await kynva.listBrands({ status: "active" });
const brand = brands.find((b) => b.name === "Acme") ?? brands[0];
const res = await kynva.generate({
spec_type: "renderforge_request",
spec_version: "1.0",
operation: "preview",
generation_type: "image",
intent: {
identity: { request_id: crypto.randomUUID(), brand_id: brand.id, source: "direct_api" },
content: {
spec_type: "content", spec_version: "1.0",
headline: "Summer collection", cta: "Shop now",
},
assets: { spec_type: "assets", spec_version: "1.0" },
brand_kit: brand as never, // the saved BrandKitV1 — enforced by the engine
style_brief: { spec_type: "style_brief", spec_version: "1.0", mode: "auto" },
export_intent: {
spec_type: "export_intent", spec_version: "1.0",
primary: { platform: "instagram", format: "png", profile_id: "ig_square_1x1" },
},
} as never,
execution: { execution_mode: "preview", seed: 7, quality_floor: 70 },
});
console.log(res.outputs?.[0]?.url);