SmartGen

SmartGen for Image Generation (Experimental)

Experimental Feature SmartGen is currently in beta. API endpoints and behaviors may evolve as improvements are introduced.


Overview SmartGen offers a high level interface for generating images with advanced prompt engineering and precise control over image dimensions and style. It supports both FLUX and Stable Diffusion models.


Basic Example

tsCopy codeimport Cinna from 'cinna';

const cinna = new Cinna({
  apiKey: process.env['CINNA_API_KEY']
});

const response = await cinna.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
});

Parameters and Controls SmartGen accepts the following input parameters:

tsCopy code{
  // Core settings
  description: string,   // Main description of the image
  width?: number,
  height?: number,

  // AI model options
  image_model?: string,  // Default: FLUX-1-dev
  is_sd?: boolean,       // Set to true to use Stable Diffusion
  language_model?: string,  // Default: nvidia/llama-3.1-nemotron-70b-instruct

  // Visual controls (scale from 1 to 5)
  stylization_level: number,  // Artistic style versus realism
  detail_level: number,       // Level of intricacy in visual details
  color_level: number,        // Color intensity from grayscale to vivid
  lighting_level: number,     // Lighting depth from neutral to dramatic

  // Optional parameters
  must_include?: string,      // Required elements in the final output
  examples?: string[],        // Reference prompts
  quality?: 'normal' | 'high',
  num_iterations?: number,    // Overrides quality if provided
  guidance_scale?: number,    // Use 3 for FLUX, 6 for Stable Diffusion
  negative_prompt?: string,   // Excludes undesired elements (only for Stable Diffusion)
  param_only?: boolean        // If true, returns parameters without generating an image
}

Two Step Generation

You can decouple image creation into two steps for greater control:

tsCopy code// Step 1: Generate parameters
const params = await cinna.smartgen.generateImage({
  description: "A cyberpunk cityscape",
  image_model: "FLUX-1-dev",
  stylization_level: 4,
  must_include: "neon lights, flying cars",
  param_only: true
});

// Step 2: Generate the image using the parameters
const imageResult = await cinna.images.generate({
  ...params.parameters
});

Response Format (if param_only is true)

jsonCopy code{
  "parameters": {
    "prompt": "enhanced prompt string",
    "model": "FLUX-1-dev",
    "width": 1024,
    "height": 768,
    "num_iterations": 20,
    "guidance_scale": 3,
    "neg_prompt": "optional negative prompt"
  }
}

One Step Generation

For direct image creation:

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

console.log(result.url);
console.log(result.parameters);

Demonstration The following example illustrates the change in color intensity from monochrome to highly vibrant using color_level from 1 to 5:

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

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

Last updated