RemBG பின்னணி அகற்றுதல் API – டெவலப்பர் டாக்ஸ் & ஒருங்கிணைப்பு வழிகாட்டி






OpenAPI · நேரடி விளையாட்டு மைதானம்

முழு API ஐ ஆராயுங்கள்—உங்கள் உலாவியில் உண்மையான கோரிக்கைகளை இயக்கவும்

ஒவ்வொரு இறுதிப்புள்ளி, அளவுருக்கள் மற்றும் பதில்களை உலாவவும். உங்கள் API விசையுடன் கோரிக்கைகளை முயற்சிக்கவும், பிறகு /api/openapi இல் எந்த நேரத்திலும் மூல விவரக்குறிப்பைப் பெறவும்.

ஊடாடும் குறிப்பைத் தொடங்கு

rembg.js இன் நிறுவல்

latest npm versionGitHub starsnpm downloadslicenseGitHub issues

npm i @remove-background-ai/rembg.js
                        

API Reference for rembg.js

@remove-background-ai/rembg.js is a zero-config Node.js wrapper for the free Rembg API, enabling background removal with simple, customizable parameters.

Parameters for RemBG.js
ParameterTypeRequiredDefaultDescription
apiKeystring
Required

Your Rembg API key
inputImagestring | Buffer | { base64: string }
Required

Image file, buffer, or base64 payload
onDownloadProgress(event) => void
Optional

Hook for upload progress events
onUploadProgress(event) => void
Optional

Hook for download progress events
options.formatwebp (default) | png
Optional
webp
Specifies the output image format. Either "webp" (default) or "png"
options.returnBase64boolean
Optional
false
Return Base64 string instead of file
options.returnMaskboolean
Optional
false
Return only the alpha mask
options.wnumber
Optional

Target width (maintains aspect ratio)
options.hnumber
Optional

Target height (maintains aspect ratio)
options.exact_resizeboolean
Optional
false
Force exact width × height (may distort)
options.anglenumber
Optional
0
Rotation angle in degrees
options.expandboolean
Optional
true
Add padding so rotated images aren’t cropped
options.bg_colorstring
Optional
-
Optional solid background color in hex (e.g. #FFFFFFFF) or named color (e.g. "red", "blue")
  • உங்கள் சூழலை அமைத்தல்: உங்களின் திட்ட ரூட்டில் உங்கள் API விசையை உள்ளடக்கிய .env கோப்பு இருப்பதை உறுதிசெய்யவும்.

  • தேவையான தொகுதிகளை இறக்குமதி செய்தல்: @remove-background-ai/rembg.js இலிருந்து rembg செயல்பாட்டை இறக்குமதி செய்வதன் மூலம் தொடங்கவும் மற்றும் சூழல் மாறிகளைக் கையாள dotenv தொகுதி.

  • முன்னேற்ற அழைப்புகளை உள்ளமைத்தல்: கோப்பு செயல்பாடுகளின் முன்னேற்றத்தைக் கண்காணிக்க நூலகம் onDownloadProgress மற்றும் onUploadProgress கால்பேக்குகளை வழங்குகிறது. வழங்கப்பட்ட எடுத்துக்காட்டில், இந்த நிகழ்வுகளை நேரடியாக கன்சோலில் பதிவு செய்கிறோம்.

இப்போது, மாதிரி பயன்பாட்டைக் கூர்ந்து கவனிப்போம்:


// script.mjs file

import  { rembg } from '@remove-background-ai/rembg.js';
import dotenv from 'dotenv';
// Load environment variables from .env file
dotenv.config();

// API_KEY will be loaded from the .env file
const API_KEY = process.env.API_KEY;

// log upload and download progress
const onDownloadProgress = console.log;
const onUploadProgress = console.log;
rembg({
    apiKey: API_KEY,
    inputImage: './input.png', //inputImage can be one of these: string | Buffer | { base64: string };
    onDownloadProgress,
    onUploadProgress
}).then(({ outputImagePath, cleanup }) => {
    console.log('✅🎉 background removed and saved under path=', outputImagePath);
    // if called, it will cleanup (remove from disk) your removed background image
    // cleanup();
});
					
						

பின்னணியை அகற்றிய பிறகு, உங்கள் வட்டில் இருந்து செயலாக்கப்பட்ட படத்தை அகற்ற விரும்பினால், சுத்தம் செய்யும் செயல்பாட்டை அழைக்கலாம்.

முன்னேற்றப் பட்டியைக் காட்டுகிறது

பின்புலத்தை அகற்றும் சேவையை ஒருங்கிணைக்கும் போது, பயனர்களின் பதிவேற்றம் அல்லது பதிவிறக்கக் கோரிக்கையின் முன்னேற்றம் குறித்த கருத்துகளை வழங்குவது பயனளிக்கும். இதை எளிதாக்க, உங்கள் சொந்த onDownloadProgress மற்றும் onUploadProgress கால்பேக்குகளை நீங்கள் வரையறுக்கலாம். இந்த இரண்டு கால்பேக்குகளும் AxiosProgressEvent ஒரு நிகழ்வு அளவுருவாக ஏற்கின்றன. கோரிக்கை தொடரும் போது, ​​இந்த கால்பேக்குகள் பல முறை செயல்படுத்தப்படுகின்றன, உதாரணமாக, ஒரு முன்னேற்றப் பட்டியைக் காண்பிக்கவும், முன்னேற்றத்தின் அடிப்படையில் அதன் நீளத்தை சரிசெய்யவும் உங்களை அனுமதிக்கிறது.


 (base) root@DESKTOP-C0Q8KK7:~/rembg.js-test# node index.mjs
 {
   loaded: 65687,
   total: 68474,
   progress: 0.9592984198381868, <---- @95% progress 
   bytes: 65687,
   rate: undefined,
   estimated: undefined,
   upload: true  <---- upload progress
 }
 {
   loaded: 68474,
   total: 68474,
   progress: 1, <---- @100% progress 
   bytes: 2787,
   rate: undefined,
   estimated: undefined,
   upload: true <---- upload progress 
 }
 {
   loaded: 1002,
   total: 68824,
   progress: 0.014558874811112402, <---- @1% progress 
   bytes: 1002,
   rate: undefined,
   estimated: undefined,
   download: true <---- download progress 
 }
 {
   loaded: 68824,
   total: 68824,
   progress: 1, <---- @100% progress 
   bytes: 67822,
   rate: undefined,
   estimated: undefined,
   download: true <---- download progress
 }
 ✅🎉 background removed and saved under path=/tmp/rembg--3339-DBqqeJ2eOs4D-.png
					

உறுப்பினர் மற்றும் கடன்களின் பயன்பாடு

உங்கள் திட்ட லேபிள், சேர்க்கப்பட்ட மற்றும் ப்ரீபெய்ட் கிரெடிட் நிலுவைகள் மற்றும் பயன்பாடு ஆகியவற்றை வழங்குகிறது. நீங்கள் UTC காலண்டர் மாதம் (மரபுவழி), கோடு-சீரமைக்கப்பட்ட பில்லிங் காலம் (புதுப்பித்தல் மூலம் கண்காணிக்க) அல்லது அறியப்பட்ட பில்லிங் காலங்களை பட்டியலிடலாம். உங்கள் API விசையுடன் மட்டும் அங்கீகரிக்கவும்.

ஸ்கீமாக்கள், எடுத்துக்காட்டுகள் மற்றும் ட்ரை-இட் கன்சோலுக்கு, முழுக் குறிப்பில் அதே இறுதிப்புள்ளியைப் பார்க்கவும்: API ஆவணத்தைத் திற

இறுதிப்புள்ளி
GET https://www.rembg.com/api/membership-usage
அங்கீகாரம்

உங்கள் API விசையை அனுப்பவும்: தலைப்பு x-api-key: YOUR_API_KEY_HERE (rembg.com இல் உங்கள் சுயவிவரத்தில் விசைகளை உருவாக்கி நிர்வகிக்கவும்).

வினவல் அளவுருக்கள்
அளவுருவகைவிளக்கம்
yearnumberகாலண்டர் ஆண்டு (1–9999). மாதத்துடன், Redis கீஸ் பயனர்:{uid}:app_usage:{year}:{month} படிக்கிறது. தவிர்க்கப்பட்டால் (மற்றும் பீரியட்ஸ்டார்ட்யூனிக்ஸ் பயன்படுத்தப்படவில்லை), தற்போதைய UTC ஆண்டிற்கு இயல்புநிலையாக இருக்கும்.
monthnumber (1–12)காலண்டர் மாதம் 1–12 (UTC மாநாடு விசைகளுக்குப் பயன்படுத்தப்படுகிறது). தவிர்க்கப்பட்டால், தற்போதைய UTC மாதத்திற்கு இயல்புநிலையாக இருக்கும்.
periodStartUnixnumberயுனிக்ஸ் நேர முத்திரை வினாடிகளில்: பில்லிங் சாளரத்தின் தொடக்கம். பயனர்:{uid}:app_usage:cycle:{periodStartUnix} மற்றும் api_usage:cycle:…. ஆண்டு அல்லது மாதத்துடன் இணைக்க முடியாது.
expandstringகமாவால் பிரிக்கப்பட்ட கொடிகள். billingCycle ஆப்ஜெக்ட்டைச் சேர்க்க, billing_cycleஐச் சேர்க்கவும்: Redis இல் billing_period_* இருக்கும் தற்போதைய ஸ்ட்ரைப் காலம், இல்லையெனில் தற்போதைய UTC காலண்டர் மாதம். ஒரு குறிப்பிட்ட சாளரத்திற்கு பீரியட்ஸ்டார்ட்யூனிக்ஸ் உடன் வேலை செய்கிறது.
includeBillingCycle1 / trueபில்லிங்_சைக்கிள் கொண்டிருக்கும் விரிவாக்கம்: பில்லிங்சைக்கிள் பொருளைச் சேர்க்க 1 அல்லது சரி என அமைக்கவும்.
listBillingCycles1 / trueஅர்ப்பணிக்கப்பட்ட பயன்முறை: listBillingCycles=1 அல்லது உண்மையான வருமானம் மட்டும் {bilingCycles: [...] }. இந்தப் பயனருக்கான சுழற்சி விசைகளுக்கு Redis ஐ ஸ்கேன் செய்கிறது; இந்த கோரிக்கையில் மற்ற வினவல் அளவுருக்கள் புறக்கணிக்கப்படுகின்றன.

ஆண்டு அல்லது மாதத்துடன் பீரியட்ஸ்டார்ட்யூனிக்ஸைக் கடக்க வேண்டாம் - ஏபிஐ 400ஐத் தருகிறது. பட்டியல் பில்லிங்சைக்கிள்ஸ் பயன்முறை தனியானது மற்றும் பிற அளவுருக்களைப் புறக்கணிக்கிறது.

பட்டியல் பில்லிங் காலங்கள்

கடந்த கால மற்றும் தற்போதைய சந்தா சாளரங்களின் கீழ்தோன்றலை விரிவுபடுத்த இதைப் பயன்படுத்தவும் (ஒவ்வொரு உள்ளீடும் பீரியட்ஸ்டார்ட்யூனிக்ஸ் ஆகும், நீங்கள் பீரியட்ஸ்டார்ட்யூனிக்ஸ்=… உடன் அனுப்பலாம்). கால முடிவு நேரங்கள் ஊகிக்கப்படுகின்றன (அடுத்த கால தொடக்கம் - 1, அல்லது செயலில் உள்ள காலத்திற்கான ஸ்ட்ரைப் தற்போதைய_பீரியட்_எண்ட்).

curl --location 'https://www.rembg.com/api/membership-usage?listBillingCycles=1' \
  --header 'x-api-key: YOUR_API_KEY_HERE'

எடுத்துக்காட்டு பதில்

{
  "billingCycles": [
    {
      "periodStartUnix": 1774268612,
      "periodEndUnix": 1776947012,
      "appUsage": 120,
      "apiUsage": 880
    }
  ]
}

புதிய காலம் முதலில் வரிசைப்படுத்தப்பட்டது. சுழற்சி பயன்பாட்டு விசை இருந்தால் அல்லது அது ஸ்ட்ரைப் வெப்ஹூக்ஸிலிருந்து தற்போதைய பில்லிங்_பீரியட்_ஸ்டார்ட் எனில் ஒரு காலம் தோன்றும்.

பில்லிங் சைக்கிள் பொருள்

விரிவாக்கம் பில்லிங்_சைக்கிளை உள்ளடக்கியது அல்லது பில்லிங் சைக்கிள் அமைக்கப்பட்டது. டாஷ்போர்டுகளுக்கு இதைப் பயன்படுத்தவும்: புதுப்பித்தல் எல்லை, சாளரத்தில் பயன்பாடு மற்றும் மீதமுள்ள வரவுகள்.

புலம்விளக்கம்
periodStartUnixபில்லிங் சாளரத்தின் தொடக்கம் (யூனிக்ஸ் வினாடிகள்). கணக்கு ஒத்திசைக்கப்படும் போது ஸ்ட்ரைப் தற்போதைய_காலம்_தொடக்கத்துடன் பொருந்தும்.
periodEndUnixதற்போதைய சாளரத்தின் முடிவு (யூனிக்ஸ் வினாடிகள்), அதாவது அடுத்த புதுப்பித்தலுக்கு சற்று முன் — ஒத்திசைக்கப்படும் போது ஸ்ட்ரைப் current_period_end. சந்தா ரத்து தேதி போன்றது அல்ல.
appUsage / apiUsageஇந்தச் சாளரத்தில் உள்ளடங்கிய கிரெடிட் உபயோகம் கணக்கிடப்படுகிறது: web/editor (app) vs API key (api). பயன்படுத்தப்பட்டIncludedCredits அவற்றின் கூட்டுத்தொகைக்கு சமம்.
includedCreditsRedis இல் சேமிக்கப்பட்டுள்ள உங்களின் சேர்க்கப்பட்ட (திட்டம்) கிரெடிட் அலவன்ஸ் (உயர்நிலை கிரெடிட்களின் அதே யோசனை).
prepaidCreditsப்ரீபெய்ட் (வாங்கிய) இருப்பு; ஒவ்வொரு பில்லிங் காலத்தையும் மீட்டமைக்காது.
usedIncludedCreditsசாளரத்தில் சேர்க்கப்பட்ட மொத்த பயன்பாடு (பயன்பாடு + API). ப்ரீபெய்டு நுகர்வு இங்கே சேர்க்கப்படவில்லை.
remainingIncludedCreditsஅதிகபட்சம்(0, சேர்க்கப்பட்ட கடன்கள் - பயன்படுத்தப்பட்டவை உள்ளிட்டவை).
stripeBillingSyncedRedis இல் ஸ்டிரைப்பில் இருந்து billing_period_start/end இருந்தால் சரி, அதனால் சாளரம் உங்கள் சந்தாவுடன் பொருந்தும்; தப்பு என்பது இந்த தொகுதிக்கான UTC காலண்டர் மாதத்திற்கு API ஆனது.

ஸ்ட்ரைப் வெப்ஹூக்குகள் பயனருக்கான பில்லிங் காலங்களை எழுதும் வரை, ஸ்ட்ரைப் பில்லிங் சிங்க்ட் தவறானதாக இருக்கலாம் மற்றும் பில்லிங்சைக்கிள் சாளரம் யுடிசி காலண்டர் மாதத்தைப் பின்பற்றும். ஒத்திசைத்த பிறகு, பட APIயின் பயன்பாட்டு வரம்புகள் அதே சுழற்சி விசைகளுடன் சீரமைக்கப்படும்.

“அடுத்த புதுப்பித்தலுக்கு முன் பயன்படுத்தப்படும் கிரெடிட்டுகளுக்கு”, Expand=billing_cycle உடன் அழைத்து, billingCycle.periodEndUnixஐ புதுப்பித்தல் எல்லையாகப் பயன்படுத்தவும், billingCycle.usedIncludedCredits (அல்லது appUsage + apiUsage) மற்றும் billingCycle.remainingIncludedCredits. ப்ரீபெய்ட் கிரெடிட்களைச் சேர்க்கவும்.

எடுத்துக்காட்டுகள் (சுருட்டை)

குறிப்பிட்ட UTC காலண்டர் மாதத்திற்கான பயன்பாடு

curl --location 'https://www.rembg.com/api/membership-usage?year=2026&month=3' \
  --header 'x-api-key: YOUR_API_KEY_HERE'

தற்போதைய பில்லிங் சுழற்சி + முழு பில்லிங் சைக்கிள் தொகுதி (ஒத்திசைக்கப்படும் போது புதுப்பித்தல்-சீரமைக்கப்பட்டது)

# Current subscription window + usage (renewal-aligned when Stripe is synced)
curl --location 'https://www.rembg.com/api/membership-usage?expand=billing_cycle' \
  --header 'x-api-key: YOUR_API_KEY_HERE'

ஒரு வரலாற்று பில்லிங் சாளரம் கால தொடக்கத்தின் அடிப்படையில் (பட்டியலிலிருந்து பில்லிங் சைக்கிள்கள் அல்லது ஸ்ட்ரைப்)

# Specific billing period by Stripe period start (unix seconds)
curl --location 'https://www.rembg.com/api/membership-usage?periodStartUnix=1774268612&expand=billing_cycle' \
  --header 'x-api-key: YOUR_API_KEY_HERE'
உதாரணம் JSON (பில்லிங் சுழற்சியுடன்)

உயர்நிலை app_usage மற்றும் api_usage ஆகியவை எப்போதும் கோரப்பட்ட காலண்டர் மாதத்தை அல்லது பீரியட்ஸ்டார்ட்யூனிக்ஸ் அமைக்கப்படும் போது, அந்த சுழற்சியின் கவுண்டர்களை பிரதிபலிக்கும். Expand=billing_cycle தவிர்க்கப்பட்டால், billingCycle இல்லை.

{
  "membership": "Premium-20000",
  "credits": 18500,
  "prepaidCredits": 2000,
  "app_usage": 8500,
  "api_usage": 10000,
  "billingCycle": {
    "periodStartUnix": 1740441600,
    "periodEndUnix": 1743033599,
    "appUsage": 4200,
    "apiUsage": 5100,
    "includedCredits": 18500,
    "prepaidCredits": 2000,
    "usedIncludedCredits": 9300,
    "remainingIncludedCredits": 9200,
    "stripeBillingSynced": true
  }
}

ஸ்ட்ரைப் பில்லிங் ஒத்திசைவு உண்மையாக இருந்தால், பிலிங்சைக்கிள் பின்னணி-அகற்றுதல் API இல் அமலாக்கத்துடன் பொருந்துகிறது. தவறு எனில், காலண்டர் மாதப் புலங்களை நம்புங்கள் அல்லது வெப்ஹூக்குகள் Redis இல் billing_period_*ஐ நிரப்பும் வரை காத்திருக்கவும்.

Error Responses

All error responses return a JSON body with a status field matching the HTTP status code.

Single Error Response

HTTP/1.1 400 Bad Request

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "error": "Image width (12000px) exceeds the maximum allowed width of 10000px.",
  "field": "image",
  "status": 400
}

HTTP/1.1 400 Bad Request

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "error": "Multiple validation errors",
  "details": [
    { "field": "w", "message": "'w' must be an integer, got: 'abc'" },
    { "field": "angle", "message": "'angle' must be between -360 and 360 degrees, got: 500.0" }
  ],
  "status": 400
}
Error Reference
ScenarioStatusError Message
No image provided
400
No image file provided. Please include an 'image' field in your form data.
No file selected
400
No file selected. Please choose an image file to upload.
Unsupported file type
400
File type '.exe' is not supported. Allowed formats: webp, bmp, png, jpg, jpeg
Corrupt image
400
File does not appear to be a valid image (invalid file signature)
Empty file (0 bytes)
400
Uploaded file is empty (0 bytes).
File too large
400
File size (55.2 MB) exceeds the maximum allowed size of 50 MB.
Image too wide
400
Image width (12000px) exceeds the maximum allowed width of 10000px.
Image too tall
400
Image height (15000px) exceeds the maximum allowed height of 10000px.
Bad w or h value
400
'w' must be an integer, got: 'abc'
w or h out of range
400
'w' must be at least 1, got: -5
w or h above max
400
'w' must be at most 10000, got: 15000
Bad angle
400
'angle' must be a number, got: 'ninety'
Angle out of range
400
'angle' must be between -360 and 360 degrees, got: 500.0
Bad output format
400
Invalid format 'gif'. Allowed formats: PNG, JPEG, WEBP, BMP
Bad bg_color
400
Invalid color format '#12345'. Use hex format: #RGB, #RGBA, #RRGGBB, or #RRGGBBAA
mask + bg_color conflict
400
Cannot use 'mask=true' together with 'bg_color'. Choose one or the other.
Email not verified
403
Email address not verified – please check your inbox
Invalid API key
401
invalid api key
Both API key and user token sent
400
This is a mistake: Cannot use both API key and user token
Rate limit exceeded (short-term)
429
You're making requests too quickly, Please Upgrade or slow down.
Rate limit exceeded (daily, anonymous)
429
You've reached your daily limit. Please sign up for more access.
Rate limit exceeded (monthly, authenticated)
429
You've reached your monthly limit. Consider purchasing more credits.
Error Handling Guidelines
  • Check HTTP status code 400 to identify validation errors
  • Parse the error field for the error message
  • Check for the details array when handling multiple validation errors
  • Use the field property to map errors to specific request parameters