apyhub

Extract Hair Region from Image API

What it does

Hair Region Extractor takes a portrait image and returns the image as a binary file with a heuristic hair region extracted and transparency applied. It is designed for image pipelines that need a quick foreground-style cutout around hair without building a custom segmentation model.

Send the image in the required file field, and optionally adjust sensitivity as a query parameter between 0.1 and 1. Lower values keep the extraction conservative; higher values make the region detection more aggressive. The response is a binary image, so you can pass it straight into storage, editing, or further compositing steps.

Use Hair Region Extractor when you need to isolate hair for avatar generation, portrait retouching, virtual try-on workflows, or design tools that layer effects behind a subject. Because the output is transparent, it fits cleanly into downstream image-processing pipelines without extra masking logic.

If you are working with user-uploaded portraits, this endpoint gives you a focused transformation step: one image in, one processed image out.

POST
Extract a heuristic hair region with transparency
https://api.eu.apyhub.com/dosvak/extract-hair-region

QUICKSTART

GUIDE

Quickstart

Upload a portrait image to extract the hair region.

curl -X POST "https://api.eu.apyhub.com/dosvak/extract-hair-region" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/portrait.jpg"

What you'll get back

Returns a binary file (string with format: "binary"), which is the extracted hair-region output.

TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
Portrait image

About this endpoint

What it does

Extracts a heuristic hair region from a portrait image and returns the resulting image as binary output with transparency.

Query Parameter(s)

AttributeTypeMandatoryDescription
sensitivityNumberNoControls how aggressively the hair region is extracted. Minimum 0.1, maximum 1, default 0.55.

Request Body

ParameterTypeMandatoryDescription
fileStringYesPortrait image. Binary upload. Maximum size: 20 MB.

Response

Returns a binary file response. The output schema is a single binary string, so the success payload is the extracted image data rather than a JSON object.

Query parameters

Name
Type
Description
sensitivityOPTIONAL
number
DEFAULT 0.55

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.