Endpoint: Cost Estimate
Method + path
GET /compress/estimate/{format}
Auth
Requires X-Fast-Api-Key header.
Path params
format: file format (e.g.jpg,png,pdf,docx)
Query params
All optional. Provide the relevant parameter for the compressor's costing strategy to receive an estimatedCredits value.
| Param | Type | Used by |
|---|---|---|
fileSizeBytes | long | PerMegabyte strategy |
fileSizeMb | double | PerMegabyte strategy (convenience alias) |
If both fileSizeBytes and fileSizeMb are provided, fileSizeBytes takes precedence.
Important: If the required input for the strategy is omitted,
estimatedCreditsreturns the base cost — this is the minimum cost, not a calculated estimate. For example, a 200 MB file with a PerMegabyte strategy costs more than 1 credit, but omitting file size returnsestimatedCredits: 1. Always provide the relevant input parameter for an accurate estimate.
The costing formula and limits are always returned so clients can calculate or display the rate.
Response
200 OK with CompressCostEstimateResponse.
Example response (PerMegabyte strategy — no inputs)
When no size input is provided, estimatedCredits returns the base cost (minimum).
{
"job": "image.jpg-compress",
"category": "images",
"estimatedCredits": 1,
"costing": {
"strategy": "PerMegabyte",
"baseCost": 1,
"increment": 40,
"incrementUnit": "mb",
"displaySuffix": "per 40 MB"
},
"inputs": {
"fileSizeBytes": null,
"fileSizeMb": null
},
"limits": {
"maxFileSizeBytes": 1073741824
}
}
Example response (PerMegabyte with file size)
{
"job": "image.jpg-compress",
"category": "images",
"estimatedCredits": 3,
"costing": {
"strategy": "PerMegabyte",
"baseCost": 1,
"increment": 40,
"incrementUnit": "mb",
"displaySuffix": "per 40 MB"
},
"inputs": {
"fileSizeBytes": 125829120,
"fileSizeMb": null
},
"limits": {
"maxFileSizeBytes": 1073741824
}
}
Example response (Fixed strategy)
Compressors with Fixed costing always return the same cost regardless of file size.
{
"job": "image.gif-compress",
"category": "images",
"estimatedCredits": 1,
"costing": {
"strategy": "Fixed",
"baseCost": 1,
"increment": null,
"incrementUnit": null,
"displaySuffix": "each"
},
"inputs": {
"fileSizeBytes": null,
"fileSizeMb": null
},
"limits": {
"maxFileSizeBytes": 1073741824
}
}
Examples
# PerMegabyte (no inputs — returns base cost)
curl -sS "https://api.tools.fast/compress/estimate/jpg" \
-H "X-Fast-Api-Key: $API_KEY"
# PerMegabyte with file size (bytes)
curl -sS "https://api.tools.fast/compress/estimate/jpg?fileSizeBytes=52428800" \
-H "X-Fast-Api-Key: $API_KEY"
# PerMegabyte with file size (MB convenience alias)
curl -sS "https://api.tools.fast/compress/estimate/pdf?fileSizeMb=50" \
-H "X-Fast-Api-Key: $API_KEY"
# Fixed strategy (file size doesn't affect cost)
curl -sS "https://api.tools.fast/compress/estimate/gif" \
-H "X-Fast-Api-Key: $API_KEY"
# Unsupported format (returns 400)
curl -sS "https://api.tools.fast/compress/estimate/mp3" \
-H "X-Fast-Api-Key: $API_KEY"# PerMegabyte (no inputs — returns base cost)
Invoke-RestMethod "https://api.tools.fast/compress/estimate/jpg" `
-Headers @{ "X-Fast-Api-Key" = $env:API_KEY }
# PerMegabyte with file size (bytes)
Invoke-RestMethod "https://api.tools.fast/compress/estimate/jpg?fileSizeBytes=52428800" `
-Headers @{ "X-Fast-Api-Key" = $env:API_KEY }
# PerMegabyte with file size (MB convenience alias)
Invoke-RestMethod "https://api.tools.fast/compress/estimate/pdf?fileSizeMb=50" `
-Headers @{ "X-Fast-Api-Key" = $env:API_KEY }
# Fixed strategy (file size doesn't affect cost)
Invoke-RestMethod "https://api.tools.fast/compress/estimate/gif" `
-Headers @{ "X-Fast-Api-Key" = $env:API_KEY }
# Unsupported format (returns 400)
Invoke-RestMethod "https://api.tools.fast/compress/estimate/mp3" `
-Headers @{ "X-Fast-Api-Key" = $env:API_KEY }Error responses
400 Bad Request if the format is not supported:
{
"error": "estimate.unsupported_format",
"detail": "No compressor found for format 'mp3'.",
"format": "mp3",
"supportedFormats": ["avif", "bmp", "docx", "gif", "heic", "jpg", "pdf", "png", "pptx", "webp"]
}