> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://developer.ideogram.ai/v1/api-reference/tools/remove-background/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.ideogram.ai/_mcp/server. # Remove Background POST https://api.ideogram.ai/v1/remove-background Content-Type: multipart/form-data Remove the background of a given image synchronously. The foreground subject is identified and returned on a transparent background. Supported image formats include JPEG, PNG, and WebP. Image links are available for a limited period of time; if you would like to keep the image, you must download it. Reference: https://developer.ideogram.ai/v1/api-reference/tools/remove-background ## Authentication - `Api-Key` header (required) — API key for access control. Use in the header with the name \"Api-Key\" ## Request ### Body (multipart/form-data) This endpoint expects a multipart form containing a file. - `image` (file, required) — The image whose background is being removed (max size 25MB); only JPEG, WebP and PNG formats are supported at this time. ## Response ### 200 Background removed successfully. - `created` (datetime, required) — The time the request was created. - `data` (list of RemoveBackgroundImageObject, required) — A list containing the single foreground image. The endpoint always returns exactly one entry. ## Errors ### 400 Bad Request Error Invalid input provided. - `any` ### 401 Unauthorized Error Not authorized to remove background. - `any` ### 422 Unprocessable Entity Error Initial image failed the safety checks. - `error` (string, required) ### 429 Too Many Requests Error Too many requests. - `any` ## Types ### RemoveBackgroundImageObject - `is_image_safe` (boolean, required) — Whether the foreground image passes safety checks. If false, the url field will be empty. - `url` (string, optional, nullable) — The direct link to the foreground image. Empty when the image fails safety checks. ## Examples **Request** ```json { "image": "" } ``` **Response** ```json { "created": "2024-01-15T09:30:00Z", "data": [ { "is_image_safe": true, "url": "https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89" } ] } ``` **SDK Code** ```python import requests url = "https://api.ideogram.ai/v1/remove-background" files = { "image": "open('[object Object]', 'rb')" } headers = {"Api-Key": ""} response = requests.post(url, files=files, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.ideogram.ai/v1/remove-background'; const form = new FormData(); form.append('image', '[object Object]'); const options = {method: 'POST', headers: {'Api-Key': ''}}; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.ideogram.ai/v1/remove-background" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Api-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.ideogram.ai/v1/remove-background") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Api-Key"] = '' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.ideogram.ai/v1/remove-background") .header("Api-Key", "") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.ideogram.ai/v1/remove-background', [ 'multipart' => [ [ 'name' => 'image', 'filename' => '[object Object]', 'contents' => null ] ] 'headers' => [ 'Api-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.ideogram.ai/v1/remove-background"); var request = new RestRequest(Method.POST); request.AddHeader("Api-Key", ""); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Api-Key": ""] let parameters = [ [ "name": "image", "fileName": "[object Object]" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.ideogram.ai/v1/remove-background")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```