remove-to-quickstart
# 1. Create a job and get a signed upload_url (5 min TTL)
API="https://api.removeto.com/v1"
KEY="rmv_live_..." # your key, never in the browser
FILE="./product.png"
MIME="image/png"
SIZE=$(wc -c < "$FILE" | tr -d " ")
BODY="{\"content_type\":\"$MIME\",\"file_size\":$SIZE,\"output_format\":\"png\"}"
UPLOAD_JSON=$(curl -sS -X POST "$API/upload-url" \
-H "x-api-key: $KEY" -H "Content-Type: application/json" \
-d "$BODY")
JOB_ID=$(printf '%s' "$UPLOAD_JSON" | jq -r .job_id)
UPLOAD_URL=$(printf '%s' "$UPLOAD_JSON" | jq -r .upload_url)
# 2. Upload the binary to temporary storage (same Content-Type, no x-api-key)
curl -sS -X PUT "$UPLOAD_URL" -H "Content-Type: $MIME" \
--data-binary "@$FILE" -o /dev/null -w "upload HTTP %{http_code}\n"
# 3. AI cutout (1 credit; 120 s timeout)
curl -sS --max-time 120 -X POST "$API/remove-bg" \
-H "x-api-key: $KEY" -H "Content-Type: application/json" \
-d "{\"job_id\":\"$JOB_ID\"}"
import { readFile } from "node:fs/promises";
const API = "https://api.removeto.com/v1";
const KEY = process.env.REMOVETO_API_KEY ?? "";
async function json(response) {
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
return response.json();
}
const file = await readFile("./product.png");
// 1. Create a job and get a signed upload_url (5 min TTL)
const signed = await json(
await fetch(`${API}/upload-url`, {
method: "POST",
headers: { "x-api-key": KEY, "Content-Type": "application/json" },
body: JSON.stringify({
content_type: "image/png",
file_size: file.byteLength,
output_format: "png",
}),
}),
);
// 2. Upload the binary to temporary storage (same Content-Type, no x-api-key)
const put = await fetch(signed.upload_url, {
method: "PUT",
headers: { "Content-Type": "image/png" },
body: file,
});
if (!put.ok) throw new Error(`upload HTTP ${put.status}`);
// 3. AI cutout (1 credit; 120 s timeout)
const result = await json(
await fetch(`${API}/remove-bg`, {
method: "POST",
headers: { "x-api-key": KEY, "Content-Type": "application/json" },
body: JSON.stringify({ job_id: signed.job_id }),
signal: AbortSignal.timeout(120_000),
}),
);
console.log(result.result_url, result.download_url);
import os
import httpx
API = "https://api.removeto.com/v1"
KEY = os.environ["REMOVETO_API_KEY"]
with open("./product.png", "rb") as handle:
file_bytes = handle.read()
# 1. Create a job and get a signed upload_url (5 min TTL)
with httpx.Client(timeout=30.0) as client:
created = client.post(
f"{API}/upload-url",
headers={"x-api-key": KEY},
json={
"content_type": "image/png",
"file_size": len(file_bytes),
"output_format": "png",
},
)
created.raise_for_status()
payload = created.json()
# 2. Upload the binary to temporary storage (same Content-Type, no x-api-key)
uploaded = client.put(
payload["upload_url"],
headers={"Content-Type": "image/png"},
content=file_bytes,
)
uploaded.raise_for_status()
# 3. AI cutout (1 credit; 120 s timeout)
with httpx.Client(timeout=120.0) as client:
result = client.post(
f"{API}/remove-bg",
headers={"x-api-key": KEY},
json={"job_id": payload["job_id"]},
)
result.raise_for_status()
print(result.json())