Generate Images with AIGen SDK (Node.js)

Create AI-generated images effortlessly using the AIGen SDK. Whether you want to build beautiful hero sections, dynamic banners, social media visuals, or personalized marketing creatives — this guide covers all you need to know.

🚀 Tip: Use npx aigen-sdk to run CLI commands instantly without installing anything!


🛠️ SDK Usage

Basic Example

import AigenSDK from 'aigen-sdk'

const aigen = new AigenSDK('your-secret-key')

const url = await aigen.generateImage('a beautiful sunset over the ocean', {
  width: 768,
  height: 512,
  model: 'gpt-image-1@openai'
})

console.log('Generated URL:', url)

🧩 Prompt Writing Tips

Here are some ideas to make your generations stand out:

GoalPrompt Example
Transparent BG"Remove the background and make it transparent. Keep the main subject crisp and clear."
Merge visuals (coming soon)"Combine the product with a clean white background and add elegant text. Make it look like a high-end ad."
Social visuals"A professional Instagram story for a fitness brand featuring a bold call to action."
Localized content"Translate this image into Spanish, keeping layout and style intact."

Tip: Always describe:

  • What you want
  • The style or vibe
  • Elements to keep or change

📐 Image Sizes

Choose from popular presets for every need:

NameWidthHeightGroup
Landscape768512
Square512512
Portrait512768
Instagram Post10801080Social Media
Instagram Story10801920Social Media
Facebook Post1200630Social Media
YouTube Thumbnail1280720Social Media
Pinterest Pin10001500Social Media
Favicon3232Web & Branding
Open Graph1200630Web & Branding
Twitter Card1200628Web & Branding
Website Hero19201080Web & Branding
iOS App Store10241024App Icons
Android Play Store512512App Icons

Use these sizes in your options:

width: 1080,
height: 1920  // Instagram Story

🎨 Use Cases & Examples

🧼 Remove Background

const url = await aigen.generateImage(
  'Remove the background and make it transparent. Keep the subject sharp.',
  {
    original: 'https://images.pexels.com/photos/1036623/pexels-photo-1036623.jpeg',
    model: 'gpt-image-1@openai'
  }
)

🌄 Edit Existing Image

const url = await aigen.generateImage(
  'Change the color of the car to bright red and add mountains in the background.',
  {
    original: 'https://images.pexels.com/photos/1592384/pexels-photo-1592384.jpeg',
    model: 'gpt-image-1@openai'
  }
)

📢 Generate Ads for Different Markets

const url = await aigen.generateImage(
  'Recreate this advertisement with African models for a Nigerian market. Keep the brand style.',
  {
    original: 'https://images.pexels.com/photos/1644888/pexels-photo-1644888.jpeg',
    model: 'gpt-image-1@openai'
  }
)

🌍 Use Profile Data and Profile Picture in Prompts

const url = await aigen.generateImage(
  'Create a birthday card for $$profile.name$$ with confetti and balloons.',
  {
    profile: 'instagram:username',
    model: 'gpt-image-1@openai'
  }
)
VariableMeaning
$$profile.name$$Full name
$$profile.username$$Handle
$$profile.bio$$Bio
$$profile.country$$Country (only Linked in)
$$profile.location$$City (only Linked in)

The user social picture is automatically imported. You can ask to change the background, product placement, creating memes, ...


⚙️ Full Option List

await aigen.generateImage(prompt, {
  width: 768,
  height: 768,
  model: 'gpt-image-1@openai',
  original: 'https://...', // Optional, the original image to include in the generation or to change
  profile: 'facebook:username', // Optional, it automatically imports the user profile picture and data (use it with original for product placement)
  duration: 24 // Optional, validity of the signed URL in hours
})

Here's a detailed breakdown of all the options you can use with the generateImage method (SDK) or the generate command (CLI):

OptionTypeDescription
promptstringThe core text describing the image you want to generate. Be specific and visual.
widthnumberThe width of the image in pixels. Choose from standard sizes or set custom dimensions.
heightnumberThe height of the image in pixels.
originalstring (URL)(Optional) A URL to an image that you want to use as a base or modify. Great for background removal, recoloring, or localized ad variations.
modelstring(Optional) The image generation model to use. If not set, defaults to flux-schnell@black-forest-labs. See model pricing
durationnumber(Optional) How many hours the generated signed URL should be valid for. Default is 24 hours.
profilestring(Optional) Import a social profile using format like facebook:username. You can access profile data in the prompt (e.g., $$profile.name$$) or use the profile image as a base. Compatible with instagram, Facebook and LinkedIn profiles.

🔗 Learn More


❤️ Build creative magic at scale — with aigen.run