Development Documents
AI Model API
flux-schnell API Usage Guide
10min
introduction this document will guide developers on how to use the aonweb library to call the flux schnell api, the fastest image generation model tailored for local development and personal use prerequisites node js environment aonweb library installed valid aonet appid basic usage 1\ import required modules import { ai, aioptions } from 'aonweb'; 2\ initialize ai instance const ai options = new aioptions({ appid 'your app id here', dev mode true }); const aonweb = new ai(ai options); 3\ prepare input data example const data = { input { "prompt" "black forest gateau cake spelling out the words \\\\"flux schnell\\\\", tasty, food photography, dynamic shot", "num outputs" 1, "aspect ratio" "1 1", "output format" "webp", "output quality" 90 } }; const data = { input { "num outputs" 1, "prompt" "pov someone holding their hand up, stunning black forest mountains", "aspect ratio" "1 1", "output format" "webp", "output quality" 90 } }; const data = { input { "num outputs" 1, "prompt" "3 magical wizards stand on a yellow table\\\non the left, a wizard in black robes holds a sign that says โaiโ\\\nin the middle, a witch in red robes holds a sign that says โisโ\\\nand on the right, a wizard in blue robes holds a sign that says โcoolโ\\\nbehind them a purple dragon", "aspect ratio" "1 1", "output format" "webp", "output quality" 90 } }; 4\ call the ai model const price = 8; // cost of the ai call try { const response = await aonweb prediction("/predictions/ai/flux schnell\@iaon", data, price); // handle response console log("flux schnell result ", response); } catch (error) { // error handling console error("error generating ", error); } parameter description num outputs number, number of outputs to generate prompt string, prompt for generated image aspect ratio string, aspect ratio for the generated image output format string, format of the output images output quality number,quality when saving the output images, from 0 to 100 100 is best quality, 0 is lowest quality not relevant for png outputs notes the api may take some time to process the input and generate the result, consider implementing appropriate wait or loading states handle possible errors, such as network issues, invalid input, or api limitations example response the api response will contain the url of the generated image or other relevant information parse and use the response data according to the actual api documentation