API Endpoint Reference
/api/v1/compress-image
Compress JPG/PNG/WEBP images.
Auth
Bearer or X-API-Key
Every request must include a valid user API key.
Estimate first
Preview token cost
Estimate endpoints help validate input and expected usage before processing.
Response
Download URL on success
Successful sync responses return a result URL plus token details.
Tool Usage Notes
If one image is processed, you get a single file.
If multiple images are processed, you get a ZIP file.
For lossy profiles, system avoids returning larger files than original when possible.
Estimate Before Processing
Use the estimate endpoint to preview token cost and validate your input URLs before starting conversion.
curl -X POST https://your-domain.example/api/v1/compress-image/estimate \
-H "Authorization: Bearer fm_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"inputs": ["https://example.com/file"],
"response_type": "json"
}'
{
"ok": true,
"tool": "compress-image",
"mode": "estimate",
"estimated_tokens": 1,
"available_tokens": 10,
"enough_tokens": true,
"shortfall_tokens": 0
}
Example Request
Select a compression profile for each request.
curl -X POST https://your-domain.example/api/v1/compress-image \
-H "Authorization: Bearer fm_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"inputs": ["https://example.com/image.jpg"],
"profile": "balanced",
"response_type": "json"
}'
Request Parameters Breakdown
| Parameter | Required | Type | Options | Default | Example |
|---|---|---|---|---|---|
| inputs | Yes | array<string> | HTTP/HTTPS URL(s) to JPG, PNG, WEBP files | none (required) |
["https://example.com/image.jpg"]
|
| Provide one or more image URLs. | |||||
| profile | Yes | string |
lossless, balanced, maximum
|
none (required) |
balanced
|
| Compression profile applied to all input files. | |||||
| response_type | No | string |
json, xml, text
|
json |
json
|
| Controls API response payload format. | |||||
| promo_code | No | string | Any active promo code | empty |
SPRING25
|
| Optional; applies discount rules when valid. | |||||
Example Response
Compressed image package is available at the returned URL.
{
"ok": true,
"tool": "compress-image",
"mode": "sync",
"status": "completed",
"download_url": "https://your-domain.example/tool/compress-image/jobs/.../download",
"estimated_tokens": 1,
"final_tokens": 1
}
Response Fields Breakdown
| Field | Type | Always Returned | Example |
|---|---|---|---|
| ok | boolean | Yes |
true
|
| Indicates success/failure. | |||
| tool | string | Yes |
compress-image
|
| Tool identifier. | |||
| mode | string | Yes |
sync
|
| Current execution mode. | |||
| status | string | Yes |
completed
|
| Processing state. | |||
| download_url | string | Yes |
https://your-domain.example/tool/compress-image/jobs/.../download
|
| Single file or ZIP download URL. | |||
| estimated_tokens | integer | Yes |
1
|
| Estimated reserved tokens. | |||
| final_tokens | integer | Yes |
1
|
| Final charged tokens. | |||