generate
Initiates an image generation run or image edit using the ImagineoAI API. Supports multiple model types including Flux Dev, OpenAI, Google Imagen4, Flux Kontext Max, Flux Kontext Multi, WAN Image 2.1, WAN Image 2.2, Nanobanana, and Qwen Image Edit.
Signature:
client.images.generate(input: GenerateImageInput): Promise<GenerateImageOutput | null>
- input:
GenerateImageInput(seesrc/types.tsfor full schema)- To generate a new image, provide a
promptand other parameters. - To edit an image, provide a
reference_url(URL to the image to edit) along with your prompt and options. - For Google Imagen4, include
aspect_ratioparameter (required). - For Flux Kontext Max, include
aspect_ratioparameter (optional, defaults to "1:1"). - For WAN Image 2.1, set
model_type: "wan-image-2.1"and optionally adjuststrength_model. - For WAN Image 2.2 (dual LoRA), set
model_type: "wan-image-2.2"and provide bothlora_low_nameandlora_high_name. - For Qwen Image Edit, set
model_type: "qwen-image-edit"with optional LoRA and strength parameters.
- To generate a new image, provide a
- Returns:
GenerateImageOutputornullif the API returns 204 No Content - Throws: On validation, network, or API error.
Examples
Generate an image with Flux Dev (default)
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const result = await client.images.generate({
prompt: 'A cat in a spacesuit',
model_type: 'flux-dev', // Optional, this is the default
width: 512,
height: 512,
});
if (result) {
console.log(result.image_url);
}
Generate an image with Google Imagen4
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const result = await client.images.generate({
prompt: 'A futuristic city at sunset',
model_type: 'google-imagen4',
aspect_ratio: '16:9', // Required for Google Imagen4
reference_image_url: 'https://example.com/style-reference.jpg' // Optional style reference
});
if (result) {
console.log(result.image_url);
}
Generate an image with Flux Kontext Max
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const result = await client.images.generate({
prompt: 'A majestic dragon soaring through clouds at golden hour',
model_type: 'flux-kontext-max',
aspect_ratio: '16:9', // Optional, defaults to "1:1"
seed: 42, // Optional, for reproducible results
});
if (result) {
console.log(result.image_url);
}
Generate an image with Nanobanana
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const result = await client.images.generate({
prompt: 'A vibrant underwater scene with coral reefs',
model_type: 'nanobanana',
reference_image_url: 'https://example.com/style-guide.jpg' // Optional reference for style
});
if (result) {
console.log(result.image_url);
}
Edit an image using a reference URL
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const result = await client.images.generate({
prompt: 'Make the cat astronaut suit red',
reference_image_url: 'https://example.com/mycat.png', // URL to the image to edit
model_type: 'openai', // or 'google-imagen4' with aspect_ratio
width: 512,
height: 512,
});
if (result) {
console.log(result.image_url);
}
Generate with WAN Image 2.1
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const result = await client.images.generate({
prompt: 'A portrait in the style of the fine-tuned model',
model_id: 'your-model-uuid', // Required: Turso DB model ID
model_type: 'wan-image-2.1', // WAN Image 2.1 model
width: 1920,
height: 1088,
strength_model: 1.5, // Optional: Model strength (0-2, default: 1)
model_weight: 0.7, // Optional: Model weight (0-1)
guidance: 7.5, // Optional: Guidance scale
});
if (result) {
console.log(result.image_url);
}
Generate with WAN Image 2.2 (Dual LoRA)
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const result = await client.images.generate({
prompt: 'A professional fashion photograph with natural lighting',
model_id: 'your-model-uuid', // Required: Turso DB model ID
model_type: 'wan-image-2.2', // WAN Image 2.2 model with dual LoRA
width: 1200,
height: 1500,
lora_low_name: 'wan2.2/wan2.2-lora-instagirl-2.0/Instagirlv2.0_lownoise.safetensors', // Required
lora_low_strength: 0.5, // Optional: Low LoRA strength (0-2, default: 0.5)
lora_high_name: 'wan2.2/wan2.2-lora-instagirl-2.0/Instagirlv2.0_hinoise.safetensors', // Required
lora_high_strength: 1.0, // Optional: High LoRA strength (0-2, default: 1.0)
batch_size: 1, // Optional: Number of images to generate (1-4, default: 1)
model_weight: 0.7, // Optional: Model weight (0-1)
guidance: 7.5, // Optional: Guidance scale
});
if (result) {
console.log(result.image_url);
}
Generate with Qwen Image Edit
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const result = await client.images.generate({
prompt: 'Transform the scene into a fantasy landscape with magical elements',
model_type: 'qwen-image-edit',
lora_1: 'fantasy-style-v1', // Optional: LoRA model for style
strength_model: 1.5, // Optional: LoRA strength (0-2, default: 1)
width: 1024,
height: 1024,
});
if (result) {
console.log(result.image_url);
}
Model-Specific Notes
Flux Dev Model
- Type:
flux-dev - Default model if
model_typeis not specified - High-quality image generation with Flux architecture
- Uses
widthandheightparameters for dimensions
OpenAI Model
- Type:
openai - OpenAI's DALL-E image generation model
- Supports both image generation and editing
- Optional
reference_image_urlfor style reference
Google Imagen4
- Requires
aspect_ratioparameter (e.g., '16:9', '1:1', '9:16') - Supports style transfer via
reference_image_url - Generates high-quality images with advanced capabilities
- Optimized for specific aspect ratios
Flux Kontext Max
- Type:
flux-kontext-max - Description: Advanced image generation model with superior quality and detail
- Required Parameters:
prompt: string- The text prompt for image generation
- Optional Parameters:
aspect_ratio?: string- Aspect ratio of the generated image (defaults to "1:1")- Supported ratios: "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "4:5", "5:4", "21:9", "9:21", "2:1", "1:2"
seed?: number- Random seed for reproducible generation (integer ≥ 0)
Nanobanana
- Type:
nanobanana - Description: Replicate-based model for advanced image generation, combination, and editing
- Required Parameters:
prompt: string- The text prompt for image generation
- Optional Parameters:
reference_image_url?: string- URL of reference image for style guidance
- Features:
- Supports style transfer through reference images
- Can combine multiple images (see
combinemethod) - Supports image editing (see
edit.nanobananamethods) - Handles both JSON and FormData input formats
- Optimized for both artistic and photorealistic outputs
WAN Image 2.1
- Type:
wan-image-2.1 - Description: WAN Image generation model version 2.1
- Required Parameters:
prompt: string- The text prompt for image generationmodel_id: string- UUID of the model in Turso databasemodel_type: "wan-image-2.1"- Selects the WAN Image 2.1 modelwidth: number- Image width (64-2048)height: number- Image height (64-2048)
- Optional Parameters:
strength_model?: number- Model strength (0-2, default: 1)model_weight?: number- Model weight (0-1, default: 0.7)guidance?: number- Guidance scale (0-100, default: 7.5)
- Features:
- Optimized for fine-tuned models and LoRAs
- Batch size of 2 for better quality
- Uses specialized ComfyDeploy deployment
- Maintains compatibility with existing model permissions
WAN Image 2.2 (Dual LoRA)
- Type:
wan-image-2.2 - Description: Latest WAN Image model with dual LoRA support
- Required Parameters:
prompt: string- The text promptmodel_id: string- UUID of the modellora_low_name: string- Low LoRA model namelora_high_name: string- High LoRA model name
- Optional Parameters:
lora_low_strength?: number- Low LoRA strength (0-2, default: 0.5)lora_high_strength?: number- High LoRA strength (0-2, default: 1.0)
Flux Kontext Multi
- Type:
flux-kontext-multi - Description: Multi-image combination and generation model
- Combines multiple input images with advanced style transfer
Qwen Image Edit
- Type:
qwen-image-edit - Description: Advanced text-based image editing model powered by ComfyDeploy
- Required Parameters:
prompt: string- The text prompt describing the desired editwidth: number- Image width (64-2048)height: number- Image height (64-2048)
- Optional Parameters:
lora_1?: string- Optional LoRA model for style enhancementstrength_model?: number- LoRA strength (0-2, default: 1)negative_prompt?: string- Text describing what to avoid in the generation
- Features:
- AI-powered image editing with text prompts
- Support for negative prompts for precise control
- LoRA model integration for style customization
- Seamless integration with existing generate workflow
- No breaking changes to existing API
Available Model Types
The SDK now uses a unified set of model types:
flux-dev- Default Flux Dev modelwan-image-2.1- WAN Image version 2.1wan-image-2.2- WAN Image version 2.2 with dual LoRAflux-kontext-multi- Multi-image combinationflux-kontext-max- Advanced high-quality generationgoogle-imagen4- Google's Imagen 4 modelopenai- OpenAI's DALL-E modelnanobanana- Replicate-based model for generation and editingqwen-image-edit- Advanced text-based image editing
General Notes
- The
workflow_typeparameter is deprecated. Usemodel_typeinstead. - The method branches based on the
model_typeparameter to use the appropriate generation backend. - SDK always sends data as JSON—all files/images must be provided as URLs, not file uploads.
- Input is validated with Zod (
GenerateImageInputSchema). - Makes a POST request to
/api/v1/runs/generate. - See the API Reference for details on input/output types.