RA2 Image Editor API
Edit an existing image from a text prompt with one POST request. Upload a file or pass a base64 image, then copy code or agent instructions into your codebase.
API Tester
Production endpoint{}
Pricing & Credits
Cost Per Edit
$0.04 USD
4 credits per successful edit
Billing Policy
Success: Charged $0.04 (4 credits)
Failed: No charge
Only pay for successful edits
API Reference
POST /api/ra2-image-editor
Edit an image from a source image and a text description. Alias: /api/ra2-image-edit
Request Format
Send a POST request as multipart/form-data with these fields:
| Field | Type | Required | Description |
|---|---|---|---|
| api_key | string | Required | Your API key for authentication. The X-API-Key header is also accepted. |
| image | file | Required | Source image upload. PNG, JPEG, or WebP. Max 10 MB. |
| prompt | string | Required | Text description of the edit to apply to the source image. Max 1000 characters. |
| size | string | Optional |
Output size preset key. Default: "square".
Supported presets:
resolution is supplied.
|
| resolution | string | Optional | Explicit output size in widthxheight format. Both values must be multiples of 32, between 256 and 2048. |
| seed | integer | Optional | Fixes edit randomness for reproducible results. Omit for a random seed. |
JSON Requests
Send Content-Type: application/json instead of a file upload, replacing image with one of these fields:
| Field | Type | Required | Description |
|---|---|---|---|
| image_base64 | string | Either | Base64 encoded source image. Data URL prefixes are stripped automatically. |
| image_url | string | Either | Public URL of the source image. Max 10 MB. |
prompt, api_key, size or resolution, and seed work the same way as in the multipart form.
{
"api_key": "YOUR_API_KEY",
"prompt": "Turn the background into a sunset beach",
"image_url": "https://example.com/source.png",
"size": "square",
"seed": 42
}
Response Examples
Success Response (200 OK)
When your image is successfully edited, you'll receive:
{
"success": true,
"request_id": "ra2edit_1758500000_ab12cd34",
"image_url": "https://netwrckstatic.netwrck.com/static/uploads/ai/tools/cutout-studio-sample.webp",
"images": [
"https://netwrckstatic.netwrck.com/static/uploads/ai/tools/cutout-studio-sample.webp"
],
"prompt_used": "Turn the background into a sunset beach",
"final_prompt": "Turn the background into a sunset beach",
"credits_charged": 4,
"price_cents": 4
}
Error Responses
If something goes wrong, you'll receive one of these error responses:
401 Unauthorized
{
"error": "Authentication failed",
"status": 401
}
Check your API key is correct
402 Payment Required
{
"error": "Insufficient credits. Required: 4, Available: 0",
"status": 402
}
Add more credits to your account
400 Bad Request
{
"error": "Prompt is required",
"status": 400
}
Check your request fields, including the source image
502 Generation Error
{
"success": false,
"error": "Image generation failed. Please try again."
}
Try again in a moment
Pro Tips for Better Edits
Prompt Writing
- Describe the change, not the whole scene
- Name the region: "replace the sky with a sunset"
- Include style keywords like "watercolor", "oil painting"
- Mention lighting: "golden hour", "studio lighting"
Source Images
- PNG, JPEG, or WebP up to 10 MB
- Pass public images with
image_urlinstead of uploading - Keep the source at or above the target size for sharper output
- Match
sizeto the source aspect ratio when possible
Example Great Edits
"Turn the background into a sunset beach with palm trees, keep the subject unchanged"
"Convert this photo into a watercolor painting, soft edges, visible brush strokes"
"Replace the cloudy sky with a starry night, add a soft moon glow"
Netwrck