Image Editing
Edit images with natural language prompts using AI
Image Editing
Edit and transform images using natural language prompts with CoreViz's advanced AI image editing capabilities. Apply styles, effects, modifications, and creative transformations to your images using simple text descriptions.
Interactive Demo
Try it out ↓
Endpoint
POST /api/ai/editHeaders
| Header | Value | Required |
|---|---|---|
Content-Type | application/json | Yes |
x-api-key | Your API key | Yes |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
image | string | Yes | URL of the image to edit |
prompt | string | Yes | Natural language description of the desired edit (e.g., "make it cyberpunk style", "add vintage film effect") |
output_format | string | No | Output image format: "jpg", "png", "webp" (default: "jpg") |
quality | number | No | Output quality (1-100, default: 90) |
Example Request
Basic Image Editing
curl -X POST https://lab.coreviz.io/api/ai/edit \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"image": "https://example.com/input.jpg",
"prompt": "make it cyberpunk style"
}'Style Transfer
curl -X POST https://lab.coreviz.io/api/ai/edit \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"image": "https://example.com/photo.jpg",
"prompt": "make it look like a vintage film photo",
"output_format": "jpg",
"quality": 95
}'Creative Transformations
curl -X POST https://lab.coreviz.io/api/ai/edit \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"image": "https://example.com/landscape.jpg",
"prompt": "transform into a watercolor painting"
}'Response
Status Code: 200 OK
Response Body:
{
"edited_image": "https://lab.coreviz.io/api/ai/edited/abc123.jpg",
"original_image": "https://example.com/input.jpg",
"prompt": "make it cyberpunk style",
"processing_time": 2.34
}Response Fields
| Field | Type | Description |
|---|---|---|
edited_image | string | URL of the edited image |
original_image | string | URL of the original input image |
prompt | string | The editing prompt that was used |
processing_time | number | Time taken to process the image (in seconds) |
Error Responses
401 Unauthorized
Invalid or missing API key:
{
"error": "Unauthorized",
"message": "Invalid or missing API key"
}400 Bad Request
Invalid request parameters:
{
"error": "Bad Request",
"message": "Invalid image URL, missing prompt, or invalid parameters"
}422 Unprocessable Entity
Image could not be processed:
{
"error": "Unprocessable Entity",
"message": "Unable to process the provided image or prompt"
}429 Too Many Requests
Rate limit exceeded:
{
"error": "Too Many Requests",
"message": "Rate limit exceeded. Please try again later."
}Example Usage
JavaScript/TypeScript
const apiKey = 'YOUR_API_KEY';
const imageUrl = 'https://example.com/input.jpg';
const prompt = 'make it cyberpunk style';
const response = await fetch('https://lab.coreviz.io/api/ai/edit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
},
body: JSON.stringify({
image: imageUrl,
prompt: prompt,
output_format: 'jpg',
quality: 90,
}),
});
const data = await response.json();
console.log('Edited image URL:', data.edited_image);
console.log('Processing time:', data.processing_time, 'seconds');Python
import requests
api_key = 'YOUR_API_KEY'
image_url = 'https://example.com/input.jpg'
prompt = 'make it cyberpunk style'
response = requests.post(
'https://lab.coreviz.io/api/ai/edit',
headers={
'Content-Type': 'application/json',
'x-api-key': api_key,
},
json={
'image': image_url,
'prompt': prompt,
'output_format': 'jpg',
'quality': 90,
}
)
data = response.json()
print('Edited image URL:', data['edited_image'])
print('Processing time:', data['processing_time'], 'seconds')Node.js
const fetch = require('node-fetch');
const apiKey = 'YOUR_API_KEY';
const imageUrl = 'https://example.com/input.jpg';
const prompt = 'make it cyberpunk style';
fetch('https://lab.coreviz.io/api/ai/edit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
},
body: JSON.stringify({
image: imageUrl,
prompt: prompt,
}),
})
.then((res) => res.json())
.then((data) => {
console.log('Edited image URL:', data.edited_image);
});Use Cases
Style Transfer
Apply artistic styles to images:
async function applyStyle(imageUrl, style) {
const response = await fetch('https://lab.coreviz.io/api/ai/edit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
},
body: JSON.stringify({
image: imageUrl,
prompt: `apply ${style} style`,
}),
});
const { edited_image } = await response.json();
return edited_image;
}
// Examples
await applyStyle(imageUrl, 'vintage film');
await applyStyle(imageUrl, 'watercolor painting');
await applyStyle(imageUrl, 'oil painting');
await applyStyle(imageUrl, 'sketch');Product Photo Enhancement
Enhance product photos for e-commerce:
async function enhanceProductPhoto(imageUrl) {
const response = await fetch('https://lab.coreviz.io/api/ai/edit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
},
body: JSON.stringify({
image: imageUrl,
prompt: 'enhance product photo with professional lighting and clean background',
output_format: 'jpg',
quality: 95,
}),
});
const { edited_image } = await response.json();
return edited_image;
}Creative Content Generation
Transform images for creative projects:
async function createVariations(imageUrl) {
const styles = [
'cyberpunk aesthetic',
'vintage film look',
'minimalist design',
'dramatic lighting',
'colorful pop art style',
];
const variations = await Promise.all(
styles.map(async (style) => {
const response = await fetch('https://lab.coreviz.io/api/ai/edit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
},
body: JSON.stringify({
image: imageUrl,
prompt: style,
}),
});
const data = await response.json();
return { style, url: data.edited_image };
})
);
return variations;
}Batch Processing
Process multiple images with the same style:
async function batchEditImages(imageUrls, prompt) {
const results = await Promise.all(
imageUrls.map(async (imageUrl) => {
const response = await fetch('https://lab.coreviz.io/api/ai/edit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
},
body: JSON.stringify({
image: imageUrl,
prompt: prompt,
}),
});
const data = await response.json();
return {
original: imageUrl,
edited: data.edited_image,
processing_time: data.processing_time,
};
})
);
return results;
}
// Example: Apply vintage style to all photos
const editedPhotos = await batchEditImages(
['https://example.com/photo1.jpg', 'https://example.com/photo2.jpg'],
'make it look like a vintage film photo'
);Social Media Content
Create engaging social media content:
async function createSocialMediaVariations(imageUrl) {
const variations = [
{ platform: 'instagram', prompt: 'bright, vibrant, Instagram-worthy aesthetic' },
{ platform: 'twitter', prompt: 'clean, professional look with subtle enhancement' },
{ platform: 'linkedin', prompt: 'professional, polished appearance' },
];
const results = await Promise.all(
variations.map(async ({ platform, prompt }) => {
const response = await fetch('https://lab.coreviz.io/api/ai/edit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
},
body: JSON.stringify({
image: imageUrl,
prompt: prompt,
}),
});
const data = await response.json();
return { platform, url: data.edited_image };
})
);
return results;
}Prompt Examples
Here are some effective prompt examples for different editing tasks:
Style Transfer
"make it cyberpunk style""transform into a watercolor painting""apply vintage film aesthetic""make it look like an oil painting""convert to black and white with high contrast"
Enhancement
"enhance colors and lighting""improve sharpness and clarity""add professional lighting""increase saturation and vibrancy"
Creative Effects
"add dramatic shadows and highlights""create a dreamy, soft-focus effect""apply a cinematic color grade""make it look like a professional portrait"
Background Modifications
"remove background and make it transparent""replace background with a clean white background""blur the background while keeping the subject sharp"
Supported Image Formats
Input Formats:
- JPEG (.jpg, .jpeg)
- PNG (.png)
- WebP (.webp)
Output Formats:
- JPEG (.jpg, .jpeg) - Default
- PNG (.png)
- WebP (.webp)
Image URL Requirements
- The image URL must be publicly accessible
- HTTPS URLs are recommended
- The image must be a valid image file
- Maximum file size limits may apply (check your plan)
- Recommended maximum dimensions: 4096x4096 pixels
Processing Time
Processing time varies based on:
- Image size and complexity
- Prompt complexity
- Current server load
Typical processing times:
- Small images (< 1MB): 1-3 seconds
- Medium images (1-5MB): 3-8 seconds
- Large images (> 5MB): 8-15 seconds
Rate Limits
Rate limits vary by plan:
- Free: Limited requests per minute
- Pro: Higher rate limits
- Enterprise: Custom rate limits
Contact support for enterprise rate limit information.
Notes
- Edited images are stored temporarily and may be deleted after a period of time
- Download and store edited images in your own storage for permanent access
- Processing is asynchronous for large images
- The same image and prompt will produce consistent results
- Complex prompts may take longer to process
- Quality parameter affects file size and processing time
Best Practices
-
Be Specific: More specific prompts produce better results
- Good:
"make it look like a vintage film photo with warm tones" - Less effective:
"make it look old"
- Good:
-
Download Results: Always download and store edited images
async function downloadEditedImage(editedImageUrl) { const response = await fetch(editedImageUrl); const blob = await response.blob(); // Save to your storage } -
Handle Errors: Implement retry logic for rate limits
async function editWithRetry(imageUrl, prompt, maxRetries = 3) { for (let i = 0; i < maxRetries; i++) { try { const response = await fetch('https://lab.coreviz.io/api/ai/edit', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey, }, body: JSON.stringify({ image: imageUrl, prompt }), }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1))); continue; } return await response.json(); } catch (error) { if (i === maxRetries - 1) throw error; } } } -
Optimize Images: Resize large images before editing for faster processing
-
Cache Results: Store edited images to avoid re-processing
Learn More
- Try the Image Editing Tool to test the API interactively
- Explore Image Description for generating descriptions
- Check out Image Tagging for classification
- Visit Image Embeddings for search capabilities
- Visit CoreViz Studio for bulk processing