1. Create Task
  • Get Started
  • API Reference
    • Create Task
      • Image To Video
        POST
      • Instruct Edit
        POST
      • Try-On (Apparel)
        POST
      • Try-On (Accessories)
        POST
      • Lifestyle Scene
        POST
      • Swap Fashion Model
        POST
      • Background Replacer
        POST
      • Segment image by prompt
        POST
    • Get Upload URL
      GET
    • Upload File
      PUT
    • List Preset Materials
      GET
    • Retrieve Generation Task Status
      GET
    • Download Generated Result
      GET
    • Retrieve API Credit Usage
      GET
  • Help
    • Download File Samples
    • Error Codes
    • FAQ
  1. Create Task

Background Replacer

POST
https://api.sellerpic.ai/v1/api/generate/replaceBackground
Before creating a task, please ensure all required resources have been uploaded.
1.
Request Upload File URL
2.
Upload File
Upload file limit:
Supported formats: JPG/JPEG/PNG/WEBP (no animations)
Max file size: 10MB
Max image resolution: 4096px
Mask Image: Must be black background and white subject, matching original dimensions
1-original.pngProduct Image
50860d1854e94e7a96f1db3075831235_mask_output.pngProduct Mask
API Developer Guide
Replace TypeDescriptionRequired ParametersOutput ImagesCredit Cost
AI_BACKGROUNDReplaces the background using a preset style
Retrieve available styles (type: AI_BACKGROUND)
presetBackgroundId - ID of selected background style44
TEXT_TO_BACKGROUNDGenerates backgrounds based on text promptscustomBackgroundPrompt - Descriptive text input44
PRESET_BACKGROUND_IMAGEApplies a predefined image as background
Retrieve available images (type: BACKGROUND)
presetBackgroundId - ID of preset background image11
CUSTOM_BACKGROUND_IMAGEUses user-uploaded image as background
Upload Process:
1. Get upload URL
2. Upload file
backgroundImageKey - Key of uploaded image11
SOLID_COLOR_BACKGROUNDSets background using HEX color code (e.g. #80c699)backgroundColor - Valid HEX color string11
Concurrency Limits: 10
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.sellerpic.ai/v1/api/generate/replaceBackground' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "replaceType": "string",
    "productImageKey": "string",
    "productMaskKey": "string",
    "presetBackgroundId": "string",
    "customBackgroundPrompt": "string",
    "backgroundColor": "string",
    "backgroundImageKey": "string",
    "productImageScale": 0
}'
Response Response Example
200 - Example 1
{
  "code": 0,
  "data": {
    "id": "string"
  },
  "msg": "string",
  "success": true,
  "traceId": "string"
}

Request

Header Params
Authorization
string 
required
Example:
Bearer YOUR_API_KEY
Content-Type
string 
required
Example:
application/json
Body Params application/json
replaceType
string 
required
Replace type, must be one of: AI_BACKGROUND, TEXT_TO_BACKGROUND, PRESET_BACKGROUND_IMAGE, CUSTOM_BACKGROUND_IMAGE, SOLID_COLOR_BACKGROUND
productImageKey
string 
required
Product image storage key
productMaskKey
string 
optional
Product mask image storage key
System will perform automatic masking if not provided. For best results, uploading a custom mask is recommended.
presetBackgroundId
string 
optional
Preset background ID (for types: AI_BACKGROUND, BACKGROUND) Retrieve Preset Model List
customBackgroundPrompt
string 
optional
Custom background prompt
backgroundColor
string 
optional
Background color in hex, e.g., #80c699
backgroundImageKey
string 
optional
Background image storage key
productImageScale
number <double>
optional
Product image scale factor, default is 1.0 (range: 0.1–1.0). Only effective when backgroundReplaceType is PRESET_BACKGROUND_IMAGE, CUSTOM_BACKGROUND_IMAGE, or SOLID_COLOR_BACKGROUND.
Examples

Responses

🟢200OK
*/*
OK
Body
code
integer <int32>
required
Result code, where 0 indicates success and non-0 indicates an error.
Please refer to Error Codes
data
object (IdData«string») 
optional
id
string 
required
Task Id
msg
string 
optional
Description of the result, providing additional context or information about the operation outcome.
success
boolean 
required
traceId
string 
required
Trace ID for tracking the request across distributed systems.
🟢201Created
🟠401Unauthorized
🟠403Forbidden
🟠404Record Not Found
Previous
Swap Fashion Model
Next
Segment image by prompt
Built with