> For the complete documentation index, see [llms.txt](https://xalora-ai.gitbook.io/xalora-ai-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xalora-ai.gitbook.io/xalora-ai-docs/smartgen.md).

# SmartGen

SmartGen for Image Generation (Experimental)

> **Experimental Feature**: SmartGen is currently in beta. APIs and behaviors may change.

***

### [​](https://docs.heurist.ai/dev-guide/heurist-sdk/smartgen#overview)Overview <a href="#overview" id="overview"></a>

SmartGen provides a high-level interface for generating images with enhanced prompt engineering and dimension controls. It supports both FLUX and Stable Diffusion models.

***

### [​](https://docs.heurist.ai/dev-guide/heurist-sdk/smartgen#basic-example)Basic Example <a href="#basic-example" id="basic-example"></a>

Copy

```
import Xalora from 'xalora';

const xalora = new Xalora({
  apiKey: process.env['XALORA_API_KEY']
});

const response = await xalora.smartgen.generateImage({
  description: "A futuristic cyberpunk portrait of a young woman",
  image_model: "FLUX.1-dev",
  stylization_level: 3,
  detail_level: 4,
  color_level: 5,
  lighting_level: 2
});
```

### [​](https://docs.heurist.ai/dev-guide/heurist-sdk/smartgen#parameters-and-controls)Parameters and Controls <a href="#parameters-and-controls" id="parameters-and-controls"></a>

SmartGen accepts the following key parameters:

Copy

```
{
  // Basic settings
  description: string,   // Main image description
  width?: number,
  height?: number,

  // AI model settings
  image_model?: string,  // Default: FLUX-1-dev
  is_sd?: boolean,       // Default: false. Set it to true if we want to use stable diffusion prompt
  language_model?: string,  // Default: nvidia/llama-3.1-nemotron-70b-instruct. For image prompt generation.

  // Dimension controls (all optional, scale 1-5)
  stylization_level: number,  // Realism vs artistic style. 1: Photorealistic 5: Highly artistic
  detail_level: number,       // Amount of detail. 1: Minimalist 5: Extreme intricate
  color_level: number,        // Color intensity. 1: Monochromatic 5: Hyper-saturated
  lighting_level: number,     // Lighting drama. 1: Flat, even lighting 5: Extreme dramatic lighting

  // Optional parameters
  must_include?: string,   // Elements to always include without altering
  examples?: string[],     // Example prompts for reference
  quality?: 'normal' | 'high',  // Controls iteration count
  num_iterations?: number,     // Default is 20. If specified, this overrides quality setting
  guidance_scale?: number,     // 3 for Flux and 6 for Stable Diffusion
  negative_prompt?: string,    // Negative prompt, only applies to Stable Diffusion
  param_only?: boolean          // Default: false. Set it to true if we want to return params without execution.
}
```

### [​](https://docs.heurist.ai/dev-guide/heurist-sdk/smartgen#two-step-generation)Two-Step Generation <a href="#two-step-generation" id="two-step-generation"></a>

You can split the generation process into two steps:

Copy

```
// Step 1: Get image generation parameters
const params = await xalora.smartgen.generateImage({
  description: "A cyberpunk cityscape",
  image_model: "FLUX-1-dev",
  stylization_level: 4,
  must_include: "neon lights, flying cars",
  param_only: true  // Don't generate image yet. Only return the parameters
});

// Review and modify parameters if needed
console.log(params.parameters.prompt);

// Step 2: Call `images.generate` API to generate with the same or modified parameters
const imageResult = await xalora.images.generate({
  ...params.parameters
  // You may change some fields
});
```

#### [​](https://docs.heurist.ai/dev-guide/heurist-sdk/smartgen#response-type-in-parameter-only-mode-param-only-set-to-true)Response Type in Parameter-only Mode (`param_only` set to true) <a href="#response-type-in-parameter-only-mode-param-only-set-to-true" id="response-type-in-parameter-only-mode-param-only-set-to-true"></a>

Copy

```
{
  parameters: {
    prompt: string, // LLM-enhanced prompt
    model: string,
    width: number,
    height: number,
    num_iterations: number,
    guidance_scale: number,
    neg_prompt?: string,
  }
}
```

This allows you to preview and tweak the image generation parameters before invoking the generation method.

### [​](https://docs.heurist.ai/dev-guide/heurist-sdk/smartgen#one-step-generation)One-Step Generation <a href="#one-step-generation" id="one-step-generation"></a>

You can create an image with a simple description in one step:

Copy

```
const result = await xalora.smartgen.generateImage({
  description: "A cyberpunk cityscape",
  image_model: "FLUX-1-dev",
  stylization_level: 4,
  must_include: "neon lights, flying cars"
});

// Result image URL
console.log(result.url);

// You can inspect the image generation parameters
console.log(result.parameters);
```

#### [​](https://docs.heurist.ai/dev-guide/heurist-sdk/smartgen#demonstration)Demonstration <a href="#demonstration" id="demonstration"></a>

Here are two examples showcasing the progression from monochromatic to vibrant colors (color\_level from 1 to 5):

**Example 1: “A futuristic cyberpunk portrait of a young woman”**

<figure><img src="https://camo.githubusercontent.com/7332ad9c6f7bb6cae7d7e585b006785eb6e422131372af6f8d6d41afe4a65ffa/68747470733a2f2f696d61676564656c69766572792e6e65742f304c777170414d574c3243386f31326839556f5a65772f65366563376261352d396438392d346533652d353837382d6230393530393038383530302f7075626c6963" alt=""><figcaption></figcaption></figure>

**Example 2: “Hot air balloons in the sky”.**

<figure><img src="https://camo.githubusercontent.com/1f22e4a164eedd681c5df35d5411ff3aa2fe434eeefea6ccb23297e96f179cba/68747470733a2f2f696d61676564656c69766572792e6e65742f304c777170414d574c3243386f31326839556f5a65772f64656637656661342d366433382d343861632d633931392d6432343264653534343930302f7075626c6963" alt=""><figcaption></figcaption></figure>
