API reference · Optimisation

Convert format

POSThttps://api.imagemcpserver.com/playground/convert-format
💳 1 credit🛠️ MCP tool: convert_formatimagemcp.js convert

A straight format conversion with no model in the loop. Reach for it when a downstream tool only accepts one format, or when you want PNG screenshots delivered as WebP.

Overview

Convert an image between PNG, JPEG, WebP and other common formats.

Flat 1 credit per call.

Request

Headers

FieldTypeDescription
AuthorizationrequiredstringBearer <IMAGEMCP_API_KEY>. The header x-api-key: <key> is accepted as an alternative.
Content-Typerequiredstringapplication/json

Body parameters

FieldTypeDescription
imagerequiredstringInput image as an https URL or a base64 data URI. imageBase64 is accepted as an alias for the same value.
targetFormatstringOutput format — png, jpeg/jpg, webp, gif, bmp. Defaults to "png".

Examples

The same call in five forms. The MCP tab is what an MCP client sends under the hood; the CLI tab is what an agent with the agent skill runs.

convert_format
curl -X POST "https://api.imagemcpserver.com/playground/convert-format" \
  -H "Authorization: Bearer $IMAGEMCP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "image": "https://example.com/photo.png",
  "targetFormat": "webp"
}'

Response

Response fields

FieldTypeDescription
result.imageUrlstringConverted image (data URI).
result.originalFormatstringFormat detected on the input.
result.targetFormatstringFormat written.
result.mimeTypestringMIME type of the output.
200 OK
{
  "success": true,
  "message": "Image converted to WEBP successfully",
  "deductedCredits": 1,
  "userCredits": 2417,
  "result": {
    "imageUrl": "data:image/webp;base64,UklGRl4…",
    "originalFormat": "PNG",
    "targetFormat": "WEBP",
    "mimeType": "image/webp",
    "latency": "0.31s",
    "cost": "$0.0000",
    "deductedCredits": 1,
    "userCredits": 2417
  }
}

When it fails

Errors return success: false with a message. See errors & troubleshooting for the status codes and whether a retry is worth it.

FAQ

How is this different from compress_image?

convert_format changes the container without a quality setting; compress_image re-encodes at a quality you choose and reports how much size was saved. Use compress when the goal is a smaller file.