Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use SurgePix API to remove image background, returning a transparent PNG download URL. Use when the user says "remove background", "去背景", "抠图", "make transparent", "extract subject", or wants to isolate the subject from an image.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 112% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 73% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 163% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 119% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 212% | 0% |
Remove the background from an image and return a transparent PNG using the platform API. Use when the user asks to remove background, cut out a subject, make an image transparent, or create a PNG with no background.
This skill does not generate on-image text. Reply to the user in the same language they used in their request.
| Action | Description | |--------------------------|-------------------------------------------------------------------------| | Remove background | Pass a local file or URL; script uploads and processes in one step | | Check task status | Poll a generation task by taskId to check progress | | Batch remove backgrounds | Process multiple images sequentially and return all download links | | Download result | Retrieve the PNG download URL from the completed task |
> The script always submits the task asynchronously (the API returns a taskId immediately). The --nowait flag controls what the script does next: > - --nowait false (default) — the script polls internally until the task is succeeded/failed and returns the final download URL in one call. > - --nowait true — the script returns the taskId immediately without waiting; resolve it later with the surgepix-query-task skill.
Requirement: Set the SURGEPIX_API_KEY environment variable. Get your API Key at your platform's API management page.
bashexport SURGEPIX_API_KEY=your-api-key-here
This skill uses the script at <skills-dir>/surgepix-remove-background/scripts/remove_background.mjs.
First run — pass a local file, script uploads automatically:
bashnode "<skills-dir>/surgepix-remove-background/scripts/remove_background.mjs" \ ./photo.jpg # Script uploads the image automatically — no separate step needed. # Output (JSON): # {"ok":true,"taskId":"task_abc123","sessionId":123,"progress":"succeeded","download":"https://..."} # ← Save sessionId for retries
Not satisfied — retry with same session ID:
bashnode "<skills-dir>/surgepix-remove-background/scripts/remove_background.mjs" \ ./photo.jpg \ --session-id 123 ← Pass the sessionId from previous output (number type)
Submit task and get taskId only (do not wait for completion):
bashnode "<skills-dir>/surgepix-remove-background/scripts/remove_background.mjs" \ ./photo.jpg --nowait true # Returns JSON immediately: # {"ok":true,"async":true,"taskId":"task_abc123","sessionId":123,"progress":"processing","download":null,"hint":"..."} # Then use the surgepix-query-task skill to poll the taskId until progress becomes succeeded
Batch: remove backgrounds from multiple images:
bashnode "<skills-dir>/surgepix-remove-background/scripts/remove_background.mjs" ./img1.jpg node "<skills-dir>/surgepix-remove-background/scripts/remove_background.mjs" ./img2.jpg node "<skills-dir>/surgepix-remove-background/scripts/remove_background.mjs" ./img3.jpg
Before first use, run the environment check:
bashnode "<skills-dir>/surgepix-setup/scripts/check_env.mjs"
.env, then retry./photo.jpg)ask them to provide the sessionId printed by the last run. If this is a fresh image, omit it — the platform will auto-create a new session.
JPEG, JPG, PNG, WEBPbash node "<skills-dir>/surgepix-remove-background/scripts/remove_background.mjs" \ "<file path or URL>" \ [--session-id <sessionId>] \ [--nowait <true|false>]
--file prefix needed. The script uploads the image automatically, then calls the platform API and receives a taskId.--nowait false), the script polls GET /tasks/{taskId} every 2 seconds until status issucceeded or failed.
--nowait true to skip polling and return the taskId immediately; resolve it later with the surgepix-query-task skill..png to preserve transparency information.Sync success (--nowait false, stdout):
json{"ok":true,"taskId":"task_abc123","sessionId":123,"progress":"succeeded","download":"https://...result.png"}
Async submitted (--nowait true, stdout) — resolve later with the surgepix-query-task skill:
json{"ok":true,"async":true,"taskId":"task_abc123","sessionId":123,"progress":"processing","download":null,"hint":"..."}
Failure (stderr):
json{"ok":false,"error":"..."}
sessionId (note: it is a number type, e.g. 123) so the user can pass it in a retry if needed.sessionId.error field. Common causes:unsupported_image_format — file format not supportedimage_too_large — file exceeds 20MB--session-id 123 (number type) — both attempts appear in the same session history.| Parameter | Required | Default | Description | |--------------------------|----------|---------------|------------------------------------------------------------------------------| | <file path or URL> | Yes | — | Positional argument. Local file path or image URL; script uploads automatically before processing | | --session-id <id> | No | auto-created | Omit on first run (platform creates a new session and returns it in stdout); provide on subsequent runs to group iterations in the same session | | --nowait <true\|false> | No | false | false = synchronous: script polls internally and returns the final download. true = asynchronous: returns taskId immediately; resolve later via the surgepix-query-task skill |
.png — do not rename to .jpg as transparency will be lost.JPEG, JPG, PNG, WEBP. Max file size: 20MB.sessionId from the output (note: it is a number type, e.g. 123). If the user wants to retry (e.g. due to edge quality issues), they pass --session-id 123 in the next run — both attempts appear in the same session on the frontend.--session-id is omitted, the platform auto-creates a new session for the run.--file prefix. The script auto-detects whether it is a local file or a remote URL.check_env.mjs before first use in each session.download value from the output.Other measured skills in the registry, with their headline benchmark lift.