---
title: flux-schnell API Usage Guide
slug: flux-schnell-api-usage-guide
createdAt: 2025-01-07T10:17:54.286Z
---

## 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

:::BlockQuote
import \{ AI, AIOptions } from 'aonweb';
:::

### 2. Initialize AI Instance

:::BlockQuote
const ai\_options = new AIOptions(\{
&#x20;   appId: 'your\_app\_id\_here',
&#x20;   dev\_mode: true
});

const aonweb = new AI(ai\_options);
:::

### 3. Prepare Input Data Example

:::BlockQuote
const data = \{
&#x20;  input:\{
&#x20;     "prompt": "black forest gateau cake spelling out the words \\\\"FLUX SCHNELL\\\\", tasty, food photography, dynamic shot",
&#x20;     "num\_outputs": 1,
&#x20;     "aspect\_ratio": "1:1",
&#x20;     "output\_format": "webp",
&#x20;     "output\_quality": 90
&#x20;   }
};
:::

:::BlockQuote
const data = \{
&#x20;  input:\{
&#x20;     "num\_outputs": 1,
&#x20;     "prompt": "POV someone holding their hand up, stunning black forest mountains",
&#x20;     "aspect\_ratio": "1:1",
&#x20;     "output\_format": "webp",
&#x20;     "output\_quality": 90
&#x20;   }
};
:::

:::BlockQuote
const data = \{
&#x20;  input:\{
&#x20;     "num\_outputs": 1,
&#x20;     "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",
&#x20;     "aspect\_ratio": "1:1",
&#x20;     "output\_format": "webp",
&#x20;     "output\_quality": 90
&#x20;   }
};
:::

### 4. Call the AI Model

:::BlockQuote
const price = 8; // Cost of the AI call
try \{
&#x20;   const response = await aonweb.prediction("/predictions/ai/flux-schnell\@iAON", data, price);
&#x20;   // Handle response
&#x20;    console.log("Flux-Schnell result:", response);
} catch (error) \{
&#x20;   // Error handling
&#x20;   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.
