Web Integration
Tutorials Web Integration
Step 1: Get Your API Key
Step 2: Use Our Sample Code
const url = 'https://sdk.photoroom.com/v1/segment';
// Please replace with your own apiKey
const apiKey = "YOUR_API_KEY_HERE";
export async function removeBackground(imageFile: File): Promise<Blob> {
const formData = new FormData();
formData.append('image_file', imageFile);
const response = await fetch(url, {
method: 'POST',
headers: {
'X-Api-Key': apiKey
},
body: formData
});
if (!response.ok) {
console.error(response.json())
throw new Error('Network response was not ok');
}
const imageBlob: Blob = await response.blob();
return imageBlob;
}Step 3: Call the API
You're done!
Last updated
Was this helpful?