Skip to content
Last updated

All image endpoints return raw binary image data directly in the response body, not JSON objects. The image format and provider metadata are included in the response headers.

Response Format

Image endpoints return:

  • Body: Raw binary image data (PNG, JPEG, or WebP)
  • Content-Type: Image MIME type (image/png, image/jpeg, image/webp)
  • Headers: Provider metadata and request tracking information

Response Headers

All image endpoints include these standard headers:

Content-Type string

The MIME type of the returned image:

  • image/png - PNG format (most common)
  • image/jpeg - JPEG format (Clipdrop upscale, uncrop)
  • image/webp - WebP format (optional for some operations)

X-Provider string

The provider that processed the request:

  • openai - OpenAI image generation/editing
  • clipdrop - Clipdrop image manipulation

X-Provider-Request-Id string (optional)

The provider's unique request identifier for tracking and debugging.

X-Provider-Credits-Consumed integer (optional)

Number of credits consumed by the operation (Clipdrop only).

Example Response

HTTP/1.1 200 OK
Content-Type: image/png
X-Provider: openai
X-Provider-Request-Id: req_abc123xyz

[Binary PNG image data]

Example with Credits (Clipdrop)

HTTP/1.1 200 OK
Content-Type: image/png
X-Provider: clipdrop
X-Provider-Request-Id: req_def456
X-Provider-Credits-Consumed: 1

[Binary PNG image data]

Saving Images

Since responses contain raw binary data, save them directly to files:

Bash/cURL:

curl -X POST "https://api.aitronos.com/v1/images/generate" \
  -H "X-API-Key: $FREDDY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"provider":"openai","organization_id":"org_abc","prompt":"sunset"}' \
  --output image.png

Python:

response = requests.post(url, headers=headers, json=data)
with open("image.png", "wb") as f:
    f.write(response.content)

JavaScript:

const response = await fetch(url, {method: "POST", headers, body});
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("image.png", buffer);