Getting Started with AigenSDK
This guide will help you get started with AigenSDK and create your first AI-generated images.
Installation
You can install AigenSDK using npm / yarn / pnpm:
npm install aigen-sdk
Setting Up Your API Key
Before using AigenSDK, you need to get your API key:
- Go to https://aigen.run/ and create a free account (no credit card needed)
- Click on your avatar in the top right corner, then select "My secret keys"
- Copy your secret key for use with the SDK
Basic Usage
Initializing the SDK
import AigenSDK from 'aigen-sdk'
// Or using CommonJS:
// const AigenSDK = require('aigen-sdk')
// Initialize with your secret key
const aigen = new AigenSDK('your-secret-key')
Alternatively, set the AIGEN_SECRET environment variable and initialize without parameters
Generating an Image
// Generate an image from a text prompt
const url = await aigen.generateImage('a futuristic cityscape', {
width: 1024,
height: 768,
model: 'gpt-image-1@openai'
})
console.log('Generated URL:', url)
Using a Template
Create a template using the vibe editor at https://aigen.run/. You can add variables in text, image prompts, import user's social profiles and more. After you have finish your template click on Export and open the NodeJS SDK tab where you can find the template ID.
// Create an image from a template with variables
const templateUrl = await aigen.createImage({
template: 'templateId',
data: {
var1: 'John Doe',
var2: 'Acme Inc',
var3: 'CEO'
}
})
console.log('Image URL using the template:', templateUrl)
data property is optional. You can use it to fill all the variables you have created in the template. Use the name of the variable that you defined. Example, if the variable in the editor is $name$, use data: { name: 'Name value' }