Skip to content

Image Processing

Resize, compress, convert, watermark and read image metadata.

1. Overview

Base path: https://api.infrai.cc/v1/image
Auth header: Authorization: Bearer $INFRAI_API_KEY
bash
# Call any /v1/image capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/image/... \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json"

2. Methods (18)

2.1image.process

POST /v1/image/process

Process an image: resize, compress, convert, watermark, rotate or remove background.

Parameters

NameTypeRequiredDescription
inputImageRef { url? | base64? }
Required
Image reference as URL or base64.
widthnumberOptionalTarget width in pixels.
heightnumberOptionalTarget height in pixels.
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput image format.
qualitynumberOptionalCompression quality from 0 to 100.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ImageOpResult { image_url, mime, width?, height?, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/process \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample", "ops": [{"op": "resize"}]}'

2.2image.metadata

POST /v1/image/metadata

Read image dimensions, MIME type and EXIF metadata.

Parameters

NameTypeRequiredDescription
inputImageRef { url? | base64? }
Required
Image reference as URL or base64.

Returns

{ width, height, mime, exif? }
NameTypeDescription
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
size_bytesintegerSize of the resource in bytes
≥ 0
exifobject | nullRaw EXIF tag map; null when not read / not present.
color_spacestring | nulle.g. 'sRGB', 'CMYK'.
has_alphaboolean | nullWhether the image has an alpha channel
orientationinteger | nullEXIF orientation tag (1-8); null when unknown.
1–8

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/metadata \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample"}'

2.3image.upload

POST /v1/image/upload

上传图片资源并返回资产 id 与 URL

Parameters

NameTypeRequiredDescription
filestring
Required
要上传的图片:本地文件路径或字节数据
filenamestringOptional可选的文件名,用于存储与展示
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ImageAsset { id, url, mime, width?, height?, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/upload \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"file": "sample"}'

2.4image.get

GET /v1/image/get/{id}

按 id 读取单个图片资产的元信息

Parameters

NameTypeRequiredDescription
idstring
Required
图片资产 id

Returns

ImageAsset { id, url, mime, width?, height?, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/image/get/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.5image.delete

DELETE /v1/image/delete/{id}

按 id 删除已存储的图片资产

Parameters

NameTypeRequiredDescription
idstring
Required
要删除的图片资产 id
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

{ ok: boolean }
NameTypeDescription
deletedbooleanWhether the resource was successfully deleted
image_idstring | nullUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X DELETE https://api.infrai.cc/v1/image/delete/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.6image.resize

POST /v1/image/resize

缩放图片到指定宽高

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
widthnumberOptionalTarget width in pixels.
≥ 1
heightnumberOptionalTarget height in pixels.
≥ 1
fit"cover" | "contain" | "fill" | "inside" | "outside"Optional缩放适配模式:inside/cover/contain/fill
enlargebooleanOptional当原图小于目标尺寸时是否允许放大
default: false
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ProcessedImage { image_url, mime, width, height, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/resize \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample"}'

2.7image.crop

POST /v1/image/crop

按 xywh 矩形框裁剪图片

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
xnumber
Required
裁剪起点的横坐标(像素)
≥ 0
ynumber
Required
裁剪起点的纵坐标(像素)
≥ 0
widthnumber
Required
Target width in pixels.
≥ 1
heightnumber
Required
Target height in pixels.
≥ 1
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ProcessedImage { image_url, mime, width, height, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/crop \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample", "x": 1, "y": 1, "width": 1, "height": 1}'

2.8image.smart_crop

POST /v1/image/smart_crop

显著性感知裁剪到指定宽高比

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
aspectstring
Required
目标宽高比,例如 1:1、16:9
target"face" | "saliency"Optional裁剪聚焦目标:face(人脸)或 saliency(主体)
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ProcessedImage { image_url, mime, width, height, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/smart_crop \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample", "aspect": "sample"}'

2.9image.rotate

POST /v1/image/rotate

按角度旋转图片

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
degreesnumber
Required
旋转角度(度)
auto_orientbooleanOptional是否按 EXIF 信息自动校正方向
default: true
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ProcessedImage { image_url, mime, width, height, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/rotate \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample", "degrees": 1.0}'

2.10image.compress

POST /v1/image/compress

按质量或目标字节数压缩图片

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
qualitynumberOptionalCompression quality from 0 to 100.
1–100
target_bytesnumberOptional目标输出字节数上限,用于限定压缩后大小
≥ 1
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ProcessedImage { image_url, mime, width, height, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/compress \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample"}'

2.11image.convert

POST /v1/image/convert

把图片重新编码为另一种格式

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"
Required
Output image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ProcessedImage { image_url, mime, width, height, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/convert \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample", "format": "auto"}'

2.12image.watermark

POST /v1/image/watermark

为图片叠加文字或图片水印

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
textstringOptional水印文字内容
watermark_imageImageRef { url? | base64? | id? }Optional用作水印的图片引用(url/base64/id)
position"top_left" | "top" | "top_right" | "left" | "center" | "right" | "bottom_left" | "bottom" | "bottom_right"Optional水印位置:四角或居中
default: "bottom_right"
opacitynumberOptional水印不透明度,0 到 1 之间
0–1default: 1
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ProcessedImage { image_url, mime, width, height, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/watermark \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample"}'

2.13image.background_remove

POST /v1/image/background_remove

AI 抠图去除图片背景

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ProcessedImage { image_url, mime, width, height, bytes }
NameTypeDescription
image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
urlstringURL for this resource or endpoint
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
widthintegerWidth of the image in pixels
≥ 1
heightintegerHeight of the image in pixels
≥ 1
size_bytesintegerSize of the resource in bytes
≥ 0
sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
original_sha256string | nullSHA-256 hash of the original image before processing
ops_appliedstring[]List of image operations that were applied
cost_usdnumber | nullCost of this operation in USD
≥ 0
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/background_remove \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "sample"}'

2.14image.transformation.create

POST /v1/image/transformation/create

注册一个具名图片变换模板

Parameters

NameTypeRequiredDescription
namestring
Required
变换模板名称,用于在投放 URL 中复用
1–128 chars
transformImageTransform
Required
图片变换参数对象(宽高、格式、裁剪等)
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ImageTransformation { id, name, transform, created_at }
NameTypeDescription
transformation_idstringUnique identifier for this transformation
pattern: ^imgtf_[A-Za-z0-9]{20,}$
namestringHuman-readable name for this resource
1–128 chars
transformobjectImage transformation specification
transform.winteger | nullTarget width.
≥ 1
transform.hinteger | nullTarget height.
≥ 1
transform.f"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Format for the output image
transform.qinteger | nullEncoder quality 1-100.
1–100
transform.fit"cover" | "contain" | "fill" | "inside" | "outside"Fit mode for resizing (cover, contain, fill, inside, outside)
created_atstringISO 8601 timestamp when this resource was created
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/transformation/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "example", "transform": {}}'

2.15image.transformation.list

GET /v1/image/transformation/list

列出已注册的具名图片变换模板

Parameters

NameTypeRequiredDescription
cursorstringOptional分页游标:传入上一页返回的 next_cursor 获取下一页。
limitnumberOptional单页返回条数上限。

Returns

{ items: ImageTransformation[], next_cursor? }
NameTypeDescription
itemsobject[]Array of result items in this page
items[].transformation_idstringUnique identifier for this transformation
pattern: ^imgtf_[A-Za-z0-9]{20,}$
items[].namestringHuman-readable name for this resource
1–128 chars
items[].transformobjectImage transformation specification
items[].transform.winteger | nullTarget width.
≥ 1
items[].transform.hinteger | nullTarget height.
≥ 1
items[].transform.f"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Format for the output image
items[].transform.qinteger | nullEncoder quality 1-100.
1–100
items[].transform.fit"cover" | "contain" | "fill" | "inside" | "outside"Fit mode for resizing (cover, contain, fill, inside, outside)
items[].created_atstringISO 8601 timestamp when this resource was created
format: date-time
next_cursorstring | nullOpaque cursor to fetch the next page; null/absent if this is the last page

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/image/transformation/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.16image.batch.submit

POST /v1/image/batch/submit

提交批量图片处理任务

Parameters

NameTypeRequiredDescription
itemsArray<{ image, ops }>
Required
批处理条目数组,每项含 image 与 ops(处理步骤)
≥ 1 item
webhook_urlstringOptional任务完成时回调通知的 Webhook 地址
format: uri
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ImageJob { id, status, count, created_at }
NameTypeDescription
job_idstringUnique identifier for this async job
pattern: ^imgjob_[A-Za-z0-9]{20,}$
status"queued" | "in_progress" | "completed" | "failed" | "cancelled"Current status of this resource
total_countintegerTotal number of items across all pages
≥ 1

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/batch/submit \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"items": [{"image": "sample", "ops": [{"op": "resize"}]}]}'

2.17image.batch.status

GET /v1/image/batch/status/{id}

查询批量图片处理任务的进度

Parameters

NameTypeRequiredDescription
idstring
Required
批处理任务 job id

Returns

ImageJob { id, status, count, done, failed, results? }
NameTypeDescription
job_idstringUnique identifier for this async job
pattern: ^imgjob_[A-Za-z0-9]{20,}$
status"queued" | "in_progress" | "completed" | "failed" | "cancelled"Current status of this resource
itemsobject[]Array of result items in this page
items[].indexinteger-
≥ 0
items[].status"queued" | "in_progress" | "completed" | "failed"-
items[].resultobject | null-
items[].result.image_idstringUnique identifier for this image
pattern: ^pim_[A-Za-z0-9]{20,}$
items[].result.urlstringURL for this resource or endpoint
items[].result.format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"Output or input format (e.g. json, csv, png)
items[].result.widthintegerWidth of the image in pixels
≥ 1
items[].result.heightintegerHeight of the image in pixels
≥ 1
items[].result.size_bytesintegerSize of the resource in bytes
≥ 0
items[].result.sha256stringSHA-256 hash of the resource content
pattern: ^[a-f0-9]{64}$
items[].result.original_sha256string | nullSHA-256 hash of the original image before processing
items[].result.ops_appliedstring[]List of image operations that were applied
items[].result.cost_usdnumber | nullCost of this operation in USD
≥ 0
items[].result.created_atstringISO 8601 timestamp when this resource was created
format: date-time
items[].errorstring | nullError code when this item failed.

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/image/batch/status/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.18image.batch.cancel

POST /v1/image/batch/cancel/{id}

取消批量图片处理任务

Parameters

NameTypeRequiredDescription
idstring
Required
要取消的批处理任务 job id
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ImageJob { id, status }
NameTypeDescription
cancelledbooleanWhether the resource was successfully cancelled
job_idstring | nullUnique identifier for this async job
pattern: ^imgjob_[A-Za-z0-9]{20,}$

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/image/batch/cancel/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"job_id": "sample"}'

3. All capabilities

Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.

image.background_removePOST /v1/image/background_remove

Transform an EXISTING image by AI-removing its background. To GENERATE images with AI use ai.image.

Parameters (3)
NameTypeRequiredDescription
imageobjectRequiredImage data or reference for processing
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput or input format (e.g. json, csv, png)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
image.batch.cancelPOST /v1/image/batch/cancel/{id}

Cancel a batch image-processing job by job ID; idempotent write.

Parameters (3)
NameTypeRequiredDescription
idstringRequiredPath parameter.
job_idstringRequiredId of the image batch job to cancel.
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
image.batch.statusGET /v1/image/batch/status/{id}

Get the progress and results of a batch image-processing job by job ID.

Parameters (1)
NameTypeRequiredDescription
idstringRequiredPath parameter.
image.batch.submitPOST /v1/image/batch/submit

Submit a batch image-processing job and get a job handle, with optional webhook callback.

Parameters (4)
NameTypeRequiredDescription
itemsobject[]RequiredArray of result items in this page
≥ 1 item
webhook_urlstring | nullOptionalOptional completion callback; Infrai signs deliveries.
format: uri
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
storebooleanOptionalOpt in to RETAIN the produced asset/record in Infrai's own store (default false = stateless passthrough: process, return inline, keep nothing). When true, Infrai persists the asset, bills a self-hosted storage line item and applies a retention TTL — and only then do the *.list/get/delete read caps see it.
default: false
image.compressPOST /v1/image/compress

Transform an EXISTING image by compressing it to a target quality or byte size, optionally re-encoding. To GENERATE images with AI use ai.image.

Parameters (6)
NameTypeRequiredDescription
imageobjectRequiredImage data or reference for processing
qualityinteger | nullOptionalEncoder quality 1-100; mutually informative with target_bytes.
1–100
target_bytesinteger | nullOptionalCompress to <= this byte budget via quality binary search.
≥ 1
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput or input format (e.g. json, csv, png)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
storebooleanOptionalOpt in to RETAIN the produced asset/record in Infrai's own store (default false = stateless passthrough: process, return inline, keep nothing). When true, Infrai persists the asset, bills a self-hosted storage line item and applies a retention TTL — and only then do the *.list/get/delete read caps see it.
default: false
image.convertPOST /v1/image/convert

Transform an EXISTING image by re-encoding it to another format (jpeg/png/webp/avif). To GENERATE images with AI use ai.image.

Parameters (4)
NameTypeRequiredDescription
imageobjectRequiredImage data or reference for processing
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"RequiredOutput or input format (e.g. json, csv, png)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
storebooleanOptionalOpt in to RETAIN the produced asset/record in Infrai's own store (default false = stateless passthrough: process, return inline, keep nothing). When true, Infrai persists the asset, bills a self-hosted storage line item and applies a retention TTL — and only then do the *.list/get/delete read caps see it.
default: false
image.cropPOST /v1/image/crop

Transform an EXISTING image by cropping it to an x/y/w/h rectangle. To GENERATE images with AI use ai.image.

Parameters (8)
NameTypeRequiredDescription
imageobjectRequiredImage data or reference for processing
xintegerRequiredX coordinate for crop origin
≥ 0
yintegerRequiredY coordinate for crop origin
≥ 0
widthintegerRequiredWidth of the image in pixels
≥ 1
heightintegerRequiredHeight of the image in pixels
≥ 1
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput or input format (e.g. json, csv, png)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
storebooleanOptionalOpt in to RETAIN the produced asset/record in Infrai's own store (default false = stateless passthrough: process, return inline, keep nothing). When true, Infrai persists the asset, bills a self-hosted storage line item and applies a retention TTL — and only then do the *.list/get/delete read caps see it.
default: false
image.deleteDELETE /v1/image/delete/{id}

Delete a stored image asset by ID; idempotent write.

Parameters (1)
NameTypeRequiredDescription
idstringRequiredPath parameter.
image.getGET /v1/image/get/{id}

Get the metadata of one stored image asset (URL, MIME type, dimensions, byte size) by ID.

Parameters (1)
NameTypeRequiredDescription
idstringRequiredPath parameter.
image.metadataPOST /v1/image/metadata

Inspect an EXISTING image's metadata (dimensions, format, EXIF) without modifying it; read-only.

Parameters (1)
NameTypeRequiredDescription
imageobjectRequiredImage data or reference for processing
image.moderatePOST /v1/image/moderate

Classify an image for unsafe content (adult/violence/etc.) returning a flagged verdict plus per-category flags/scores. Real vendor dispatch: Google Vision SafeSearch, Aliyun Green image scan. service_markup applies.

Parameters (2)
NameTypeRequiredDescription
imagestringRequiredImage as data URI, URL, or base64.
vendor"google" | "aliyun"OptionalOptional vendor pin.
image.ocrPOST /v1/image/ocr

Extract text from an image (distinct from pdf.ocr) returning full text plus per-line blocks. Real vendor dispatch: Aliyun OCR, Baidu OCR, AWS Textract; self_hosted tesseract honestly degrades to a 503 when the binary is absent (no synthetic text).

Parameters (3)
NameTypeRequiredDescription
imagestringRequiredImage as data URI, URL, or base64.
languagestringOptionalOptional language hint (e.g. eng, chi_sim).
vendor"aliyun" | "baidu" | "aws" | "self_hosted"OptionalOptional vendor pin.
image.processPOST /v1/image/process

Transform an EXISTING image through a chained pipeline of ops, re-encoded once at the end. To GENERATE images with AI use ai.image.

Parameters (5)
NameTypeRequiredDescription
imageobjectRequiredThe source image, as either inline bytes (url/base64) or a stable asset reference (image_id).
opsobject[]RequiredOrdered list of image operations to apply
1–20 items
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput or input format (e.g. json, csv, png)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
storebooleanOptionalOpt in to RETAIN the produced asset/record in Infrai's own store (default false = stateless passthrough: process, return inline, keep nothing). When true, Infrai persists the asset, bills a self-hosted storage line item and applies a retention TTL — and only then do the *.list/get/delete read caps see it.
default: false
image.resizePOST /v1/image/resize

Transform an EXISTING image by resizing it with a fit mode and optional upscaling/format. To GENERATE images with AI use ai.image.

Parameters (8)
NameTypeRequiredDescription
imageobjectRequiredImage data or reference for processing
widthinteger | nullOptionalWidth of the image in pixels
≥ 1
heightinteger | nullOptionalHeight of the image in pixels
≥ 1
fit"cover" | "contain" | "fill" | "inside" | "outside"OptionalFit mode for resizing (cover, contain, fill, inside, outside)
enlargebooleanOptionalAllow upscaling beyond source dimensions; false (default) never upscales.
default: false
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput or input format (e.g. json, csv, png)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
storebooleanOptionalOpt in to RETAIN the produced asset/record in Infrai's own store (default false = stateless passthrough: process, return inline, keep nothing). When true, Infrai persists the asset, bills a self-hosted storage line item and applies a retention TTL — and only then do the *.list/get/delete read caps see it.
default: false
image.rotatePOST /v1/image/rotate

Transform an EXISTING image by rotating it, optionally auto-correcting orientation from EXIF. To GENERATE images with AI use ai.image.

Parameters (5)
NameTypeRequiredDescription
imageobjectRequiredImage data or reference for processing
degreesnumberRequiredClockwise rotation in degrees.
auto_orientbooleanOptionalApply EXIF orientation correction before rotating.
default: true
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput or input format (e.g. json, csv, png)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
image.smart_cropPOST /v1/image/smart_crop

Transform an EXISTING image with saliency-aware cropping to an aspect ratio, optionally targeting faces or subject. To GENERATE images with AI use ai.image.

Parameters (5)
NameTypeRequiredDescription
imageobjectRequiredImage data or reference for processing
aspectstringRequiredTarget aspect ratio, e.g. '1:1', '16:9'.
targetstring | nullOptionalSaliency target hint, e.g. 'face', 'auto'.
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput or input format (e.g. json, csv, png)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
image.tagPOST /v1/image/tag

Detect labels/objects in an image returning label + confidence pairs. Real vendor dispatch: Google Vision LABEL_DETECTION, AWS Rekognition DetectLabels. service_markup applies.

Parameters (3)
NameTypeRequiredDescription
imagestringRequiredImage as data URI, URL, or base64.
max_tagsintegerOptionalMaximum number of tags to return
≥ 1default: 10
vendor"google" | "aws"OptionalOptional vendor pin.
image.transformation.createPOST /v1/image/transformation/create

Register a named image-transformation template reusable in delivery URLs.

Parameters (3)
NameTypeRequiredDescription
namestringRequiredHuman-readable name for this resource
1–128 chars
transformobjectRequiredImage transformation specification
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
image.transformation.listGET /v1/image/transformation/list

Page through the registered named image-transformation templates.

No request parameters.

image.uploadPOST /v1/image/upload

Upload an image and get an asset with an ID and URL for later processing.

Parameters (3)
NameTypeRequiredDescription
filestringRequiredbase64-encoded bytes (multipart is mapped to this field at the transport layer).
filenamestring | nullOptionalFilename for the uploaded image
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
image.watermarkPOST /v1/image/watermark

Transform an EXISTING image by overlaying a text or image watermark with position and opacity. To GENERATE images with AI use ai.image.

Parameters (7)
NameTypeRequiredDescription
imageobjectRequiredImage data or reference for processing
textstring | nullOptionalText watermark content.
watermark_imageobject | nullOptionalImage watermark source (same ref shape as `image`); null when text is used.
position"top_left" | "top" | "top_right" | "left" | "center" | "right" | "bottom_left" | "bottom" | "bottom_right"OptionalPosition for the watermark (e.g. top-left, center)
default: "bottom_right"
opacitynumberOptionalWatermark opacity (0.0 to 1.0)
0–1default: 1
format"auto" | "webp" | "avif" | "jpeg" | "png" | "heic"OptionalOutput or input format (e.g. json, csv, png)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry

4. End-to-end example

A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.

A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.

python
#!/usr/bin/env python3
"""Infrai · image-process — runnable real-app example (single file, zero deps).

Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request

KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..."  # <- your key
BASE = "https://api.infrai.cc"


# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
    req = request.Request(
        BASE + path, method=method,
        data=json.dumps(body).encode() if body is not None else None,
        headers={"Authorization": f"Bearer {KEY}",
                 "Content-Type": "application/json"})
    try:
        with request.urlopen(req, timeout=60) as r:
            return json.loads(r.read())
    except error.HTTPError as e:
        return json.loads(e.read())


def show(label, resp):
    print(f"\n== {label} ==")
    print(json.dumps(resp, indent=2, ensure_ascii=False))
    return resp


# 1) image.process — POST /v1/image/process · Transform an EXISTING image through a chained pipeline of ops, re-encoded once at the end. To GENERATE images with AI use ai.image.  # NOTE: non-trivial real cost
r1 = show("image.process", infrai("POST", "/v1/image/process", {"image":{"url":"https://example.com/photo.jpg"},"ops":[{"op":"resize","params":{"width":800}},{"op":"compress","params":{"quality":80}}]}))

# 2) image.metadata — POST /v1/image/metadata · Inspect an EXISTING image's metadata (dimensions, format, EXIF) without modifying it; read-only.
r2 = show("image.metadata", infrai("POST", "/v1/image/metadata", {"image":"sample"}))