import { openAsBlob } from 'node:fs'; import { FireworksAI } from '@simplesagar/fireworksai'; const fireworksAI = new FireworksAI({ apiKey: process.env["FIREWORKS_API_KEY"] ?? "", }); async function run() { const result = await fireworksAI.images.generateFromImage({ accountId: "fireworks", modelId: "stable-diffusion-xl-1024-v1-0", bodyImage2imageGen: { initImage: await openAsBlob("/Users/plaso/Documents/API/inputs/profile_img.jpg"), cfgScale: 7, height: 1024, imageStrength: 0.75, initImageMode: "IMAGE_STRENGTH", negativePrompt: "cloudy day", prompt: "make it a cartoon character", safetyCheck: false, sampler: "K_EULER", samples: 1, seed: 0, stepScheduleEnd: 1, stepScheduleStart: 0, steps: 30, width: 1024, }, }); if (result instanceof ReadableStream) { const reader = result.getReader(); const chunks = []; while (true) { const { done, value } = await reader.read(); if (done) break; chunks.push(value); } const buffer = Buffer.concat(chunks); // Convert buffer to Base64 const base64String = buffer.toString('base64'); const dataUrl = `data:image/png;base64,${base64String}`; // Log the Data URL to the console const logStatement = `console.log("%c ", \`font-size: 1px; padding: 100px; background: url(${dataUrl}) no-repeat; background-size: contain;\`);`; console.log(logStatement); } } run();