API Documentation
Complete guide to using the Qwen Image Edit API
API Documentation
The Qwen Image Edit API provides powerful image editing capabilities through simple HTTP endpoints. This guide covers all available endpoints, parameters, and usage examples.
Authentication
All API requests require authentication using an API key. Include your API key in the request headers:
const headers = {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
};
Base URL
https://qwenimageedit.top/api
Endpoints
Text Editing
Edit or add text within images while preserving the original style and context.
Endpoint: POST /api/image/text-edit
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
image | File/URL | Yes | Source image to edit |
instruction | string | Yes | Text editing instruction |
position | object | No | Text position coordinates |
style | object | No | Text style preferences |
Example Request:
const response = await fetch('/api/image/text-edit', {
method: 'POST',
headers,
body: JSON.stringify({
image: 'https://example.com/image.jpg',
instruction: 'Change the text "Hello" to "Welcome"',
position: { x: 100, y: 50 },
style: {
fontSize: 24,
color: '#000000',
fontFamily: 'Arial'
}
})
});
const result = await response.json();
Response:
{
"success": true,
"editedImage": "https://example.com/edited-image.jpg",
"processingTime": 2.5,
"creditsUsed": 1
}
Semantic Editing
Perform high-level semantic changes to images, such as style transfer or object manipulation.
Endpoint: POST /api/image/semantic-edit
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
image | File/URL | Yes | Source image to edit |
prompt | string | Yes | Semantic editing instruction |
strength | number | No | Edit strength (0.1-1.0) |
preserveAreas | array | No | Areas to preserve during editing |
Example Request:
const response = await fetch('/api/image/semantic-edit', {
method: 'POST',
headers,
body: JSON.stringify({
image: 'https://example.com/portrait.jpg',
prompt: 'Convert to impressionist painting style',
strength: 0.8,
preserveAreas: [
{ x: 50, y: 50, width: 200, height: 200 }
]
})
});
const result = await response.json();
Batch Processing
Process multiple images in a single request for efficiency.
Endpoint: POST /api/image/batch-edit
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
images | array | Yes | Array of image URLs or files |
operations | array | Yes | Array of editing operations |
parallel | boolean | No | Process images in parallel |
Example Request:
const response = await fetch('/api/image/batch-edit', {
method: 'POST',
headers,
body: JSON.stringify({
images: [
'https://example.com/image1.jpg',
'https://example.com/image2.jpg'
],
operations: [
{
type: 'text-edit',
instruction: 'Add watermark "© 2024"',
position: { x: 10, y: 10 }
}
],
parallel: true
})
});
Error Handling
The API returns standard HTTP status codes and detailed error messages:
{
"success": false,
"error": {
"code": "INVALID_IMAGE",
"message": "The provided image format is not supported",
"details": "Supported formats: JPEG, PNG, WebP"
}
}
Common Error Codes:
INVALID_API_KEY
: Invalid or missing API keyINSUFFICIENT_CREDITS
: Not enough credits for the operationINVALID_IMAGE
: Unsupported image format or corrupted filePROCESSING_FAILED
: Image processing failedRATE_LIMIT_EXCEEDED
: Too many requests
Rate Limits
- Free tier: 10 requests per minute
- Pro tier: 100 requests per minute
- Enterprise: Custom limits
SDKs and Libraries
JavaScript/TypeScript
npm install @qwen-image-edit/sdk
import { QwenImageEdit } from '@qwen-image-edit/sdk';
const client = new QwenImageEdit({
apiKey: 'your-api-key',
baseUrl: 'https://qwenimageedit.top/api'
});
const result = await client.textEdit({
image: 'path/to/image.jpg',
instruction: 'Change text color to red'
});
Python
pip install qwen-image-edit
from qwen_image_edit import QwenImageEdit
client = QwenImageEdit(api_key='your-api-key')
result = client.text_edit(
image='path/to/image.jpg',
instruction='Change text color to red'
)
Webhooks
For long-running operations, you can use webhooks to receive notifications when processing is complete:
const response = await fetch('/api/image/text-edit', {
method: 'POST',
headers,
body: JSON.stringify({
image: 'https://example.com/large-image.jpg',
instruction: 'Complex editing task',
webhook: {
url: 'https://your-app.com/webhook',
secret: 'webhook-secret'
}
})
});
Best Practices
- Image Quality: Use high-resolution images (minimum 512x512) for better results
- Clear Instructions: Provide specific, clear editing instructions
- Error Handling: Always implement proper error handling
- Rate Limiting: Respect rate limits and implement exponential backoff
- Caching: Cache results when possible to reduce API calls
Support
For technical support and questions:
- Documentation: https://docs.qwenimageedit.com
- Email: support@qwenimageedit.com
- Discord: Join our community