Ideogram.js
A Node.js package that allows you to easily generate images from Ideogram.
⚠ Legal Disclaimer ⚠
This npm package is created for educational and research purposes. By using this package, you agree to do so at your own risk. This package is not affiliated, endorsed, or sponsored by Ideogram in any way.
Installation
Install ideogram.js to your project with npm:
npm install ideogram.js
Example Usage
A session cookie is required for ideogram.js to work. To get yours, follow these steps :
- Go to ideogram.ai and login (or create an account if you don't have one).
- Open DevTools using the
F12
key (or Option + ⌘ + J
for Mac users) on your keyboard. - Nagivate to
Application
-> Cookies
-> https://ideogram.ai/
and copy the value of the cookie called session_cookie
.
You can now send your first request to the Ideogram website!
const Ideogram = require("ideogram.js")
const ideogram = new Ideogram("SESSION_COOKIE_GOES_HERE")
ideogram.generate({
prompt: "Abstract expressionism of Mentoring and self development , 3d render, photo, wildlife photography, dark fantasy, cinematic",
aspect_ratio: "square"
})
.then(result =>{
console.log(result)
})
.catch(error =>{
return console.log(error)
})
Documentation
Initialization
const Ideogram = require("ideogram.js")
const ideogram = new Ideogram(session_cookie)
Parameter | Type | Default | Description |
---|
session_cookie | string | N/A | Your session cookie (REQUIRED) |
ideogram.generate()
ideogram.generate(generationOptions).then(result).catch(error)
The ideogram.generate()
sends a request to the Ideogram website to start a generation; It takes an Object
parameter and return an Object
.
Parameter (from Object) | Type | Default | Description |
---|
prompt | string | N/A | (REQUIRED) Description of the image(s) to generate |
aspect_ratio | string | N/A | (REQUIRED) Aspect ratio of the images to generate (accepted values are square , portrait or landscape ) |
Result (Object) | Type | Description |
---|
Object.success | boolean | true if the request was successful, false otherwise |
Object.message | string or null | Not null if Object.success is false , string explaining the error |
Object.user_id | string | Your Ideogram user ID |
Object.prompt | string | The prompt used in the request |
Object.request_id | string | The ID of the request. The request ID can be used to get information sata about a generation (status, images, etc) |
Object.aspect_ratio | string | The aspect ratio used in the request |
ideogram.getGeneration()
ideogram.getGeneration(generationId).then(result).catch(error)
The ideogram.getGeneration()
sends a request to the Ideogram website to get information about a generation; It takes a String
parameter and return an Object
.
Parameter | Type | Default | Description |
---|
generationId | string | N/A | (REQUIRED) Id of the generation you want to fetch |
Result (Object) | Type | Description |
---|
Object.success | boolean | true if the request was successful, false otherwise |
Object.message | string or null | Not null if Object.success is false , string explaining the error |
Object.request_id | string | Id of the generation |
Object.status | string | Status of the generation (can either be COMPLETED or GENERATING ) |
Object.prompt | string | The prompt used for the generation |
Object.aspect_ratio | string | The aspect ratio of the generation |
Object.has_started | boolean | Whether the generation has started or not |
Object.resolution | number | The current resolution of the images (1024 indicated the generation is completed) |
Object.height | string | The height of the images |
Object.width | string | The width of the images |
Object.images | Array or null | Array of Objects . If this value is null , it means the generation has started but the website it not yet returning images |
Image (Object.images) | Type | Description |
---|
Image.response_id | string | The ID of the image |
Object.hasLiked | boolean | true if you liked the image, false otherwise |
Object.likes | number | How many users liked your image |
Object.url | string | A direct URL to the image |
Support
If you're having issues with Ideogram.js or want to share your projects, ideas or feedbacks, you can join my support server!
Coming soon
- Ability to apply a style when sending a generation request.
- Function to get a list of all available styles.
- EventEmmiters ("generationRequestSent", "generationCompleted", etc...)