Skip to main content
POST
/
convert
/
image
Convert an image
curl --request POST \
  --url https://api.budgetpixel.com/v1/convert/image \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "file": "<string>"
}
'
import requests

url = "https://api.budgetpixel.com/v1/convert/image"

payload = { "file": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({file: '<string>'})
};

fetch('https://api.budgetpixel.com/v1/convert/image', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.budgetpixel.com/v1/convert/image",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'file' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.budgetpixel.com/v1/convert/image"

payload := strings.NewReader("{\n \"file\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.budgetpixel.com/v1/convert/image")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.budgetpixel.com/v1/convert/image")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"file\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "content_type": "image/webp",
  "credits_charged": 123,
  "filename": "photo.webp",
  "retention": "7 days",
  "size_bytes": 123,
  "url": "<string>"
}
{
"error": {
"code": "model_not_available",
"message": "<string>",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "model_not_available",
"message": "<string>",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "model_not_available",
"message": "<string>",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "model_not_available",
"message": "<string>",
"type": "invalid_request_error"
}
}
{
"error": {
"code": "model_not_available",
"message": "<string>",
"type": "invalid_request_error"
}
}

Authorizations

Authorization
string
header
required

API key as a bearer token: Authorization: Bearer bpx_live_xxx

Body

application/json
file
string
required

The image to convert — public URL, uploaded-file URL, data URI, or raw base64.

target
enum<string>
required

Output format.

Available options:
png,
jpg,
webp,
gif

Response

Converted. Download from url (valid several hours; file kept 7 days).

A completed format conversion. Download from url.

content_type
string
Example:

"image/webp"

credits_charged
integer

Credits charged for this conversion (2 image / 10 video / 3 audio).

filename
string

Suggested download filename.

Example:

"photo.webp"

retention
string
Example:

"7 days"

size_bytes
integer

Converted file size in bytes.

url
string<uri>

Signed download URL for the converted file (valid several hours; the file itself is kept 7 days).