1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const axios = require('axios');
const fs = require('fs');
const path = require('path');
async function toB64(imgPath) {
const data = fs.readFileSync(path.resolve(imgPath));
return Buffer.from(data).toString('base64');
}
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/ideogram-3-replace-background";
const data = {
"prompt": "Add a forest in the background",
"image": "toB64('https://segmind-resources.s3.amazonaws.com/output/085c3d6b-0ecd-4f79-9b41-823c451070f5-ideo-3.png')",
"rendering_speed": "DEFAULT",
"magic_prompt": "AUTO",
"style_codes": [],
"style_reference_images": []
};
(async function() {
try {
const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
console.log(response.data);
} catch (error) {
console.error('Error:', error.response.data);
}
})();
Provides a description for the image creation. Use specific prompts for detailed or themed images.
Upload the base image for editing. Ensure high resolution for best results.
Sets a reproducible seed for consistency. Keep null for unique results each time.
Adjust speed versus detail. Use 'QUALITY' for highly detailed images.
Allowed values:
Enhance prompts automatically. Choose 'AUTO' for balanced enhancements.
Allowed values:
Select specific styles to influence the output. Combine for unique aesthetics.
Use reference images for style influence. Best for specific visual styles.
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
Ideogram 3.0 introduces a robust Replace Background API that significantly advances image editing capabilities for both developers and creators. This tool is essential for those who aim to achieve precision and creativity in their visual workflows.
Background Removal and Replacement: The API proficiently isolates the primary subject of an image, enabling seamless background removal without losing detail. Users can replace backgrounds by inputting specific prompts, generating scenes that align with desired themes such as "A peaceful beach sunset." This function is particularly beneficial for graphic designers who need to adapt visual assets for different campaigns and marketers who seek dynamic content creation without intensive manual effort.
Manual Editing Tools: Refined mask tools like brush and lasso let users perfect their subject selections, crucial for tackling intricate elements like hair or accessories. This allows creators to maintain high quality and attention to detail in each edit, ensuring a polished final product.
Scalability and Batch Processing: The API supports batch editing, crucial for large projects such as e-commerce catalogs or bulk marketing materials. Controlling rendering speed and output quality ensures adaptability to diverse project requirements, optimizing workflow efficiency.
Style Customization and Upscaling: With options to upscale images up to 4,500x5,400 pixels, the API guarantees that outputs are ready for print and digital displays. Style prompts further enhance creative flexibility, allowing users to tailor images to specific aesthetics or branding guidelines.
By integrating Ideogram 3's Replace Background API, users can streamline their image editing operations, fostering creativity while minimizing manual labor, ultimately enhancing productivity and visual storytelling capabilities.