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-sdkto 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:
| Goal | Prompt 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:
| Name | Width | Height | Group |
|---|---|---|---|
| Landscape | 768 | 512 | – |
| Square | 512 | 512 | – |
| Portrait | 512 | 768 | – |
| Instagram Post | 1080 | 1080 | Social Media |
| Instagram Story | 1080 | 1920 | Social Media |
| Facebook Post | 1200 | 630 | Social Media |
| YouTube Thumbnail | 1280 | 720 | Social Media |
| Pinterest Pin | 1000 | 1500 | Social Media |
| Favicon | 32 | 32 | Web & Branding |
| Open Graph | 1200 | 630 | Web & Branding |
| Twitter Card | 1200 | 628 | Web & Branding |
| Website Hero | 1920 | 1080 | Web & Branding |
| iOS App Store | 1024 | 1024 | App Icons |
| Android Play Store | 512 | 512 | App 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'
}
)
| Variable | Meaning |
|---|---|
$$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):
| Option | Type | Description |
|---|---|---|
prompt | string | The core text describing the image you want to generate. Be specific and visual. |
width | number | The width of the image in pixels. Choose from standard sizes or set custom dimensions. |
height | number | The height of the image in pixels. |
original | string (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. |
model | string | (Optional) The image generation model to use. If not set, defaults to flux-schnell@black-forest-labs. See model pricing |
duration | number | (Optional) How many hours the generated signed URL should be valid for. Default is 24 hours. |
profile | string | (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
- 🧑💻 Get API key
- 📬 Support
❤️ Build creative magic at scale — with aigen.run
Other pages
AI models & Pricing Guide
List of all AI models you can use
Advanced Image Editing
All the options you have to edit images with AI
Generate images
All the options you have to generate images with AI
Image templates
How you can use image templates to have more fine control of the AI generated images
AIGen SDK (Node.js) Reference
This is the official reference for the AIGen Node.js SDK. Use it to generate AI images, personalize templates, and securely share results via signed URLs.