Generate images
curl --request POST \
--url https://api.pre.dev/v1/images \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "recraft/recraft-v4.1-flash",
"prompt": "A lighthouse at dawn, watercolor"
}
'import requests
url = "https://api.pre.dev/v1/images"
payload = {
"model": "recraft/recraft-v4.1-flash",
"prompt": "A lighthouse at dawn, watercolor"
}
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({
model: 'recraft/recraft-v4.1-flash',
prompt: 'A lighthouse at dawn, watercolor'
})
};
fetch('https://api.pre.dev/v1/images', 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.pre.dev/v1/images",
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([
'model' => 'recraft/recraft-v4.1-flash',
'prompt' => 'A lighthouse at dawn, watercolor'
]),
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.pre.dev/v1/images"
payload := strings.NewReader("{\n \"model\": \"recraft/recraft-v4.1-flash\",\n \"prompt\": \"A lighthouse at dawn, watercolor\"\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.pre.dev/v1/images")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"recraft/recraft-v4.1-flash\",\n \"prompt\": \"A lighthouse at dawn, watercolor\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/images")
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 \"model\": \"recraft/recraft-v4.1-flash\",\n \"prompt\": \"A lighthouse at dawn, watercolor\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1790500000,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA…",
"media_type": "image/png"
}
]
}Images and video
Images and video
POST /v1/images for image generation; POST /v1/videos with polling for video jobs.
POST
/
v1
/
images
Generate images
curl --request POST \
--url https://api.pre.dev/v1/images \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "recraft/recraft-v4.1-flash",
"prompt": "A lighthouse at dawn, watercolor"
}
'import requests
url = "https://api.pre.dev/v1/images"
payload = {
"model": "recraft/recraft-v4.1-flash",
"prompt": "A lighthouse at dawn, watercolor"
}
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({
model: 'recraft/recraft-v4.1-flash',
prompt: 'A lighthouse at dawn, watercolor'
})
};
fetch('https://api.pre.dev/v1/images', 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.pre.dev/v1/images",
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([
'model' => 'recraft/recraft-v4.1-flash',
'prompt' => 'A lighthouse at dawn, watercolor'
]),
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.pre.dev/v1/images"
payload := strings.NewReader("{\n \"model\": \"recraft/recraft-v4.1-flash\",\n \"prompt\": \"A lighthouse at dawn, watercolor\"\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.pre.dev/v1/images")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"recraft/recraft-v4.1-flash\",\n \"prompt\": \"A lighthouse at dawn, watercolor\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/images")
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 \"model\": \"recraft/recraft-v4.1-flash\",\n \"prompt\": \"A lighthouse at dawn, watercolor\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1790500000,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA…",
"media_type": "image/png"
}
]
}Both endpoints take a
Pick another model from
Use
Submitting a job needs at least 10 credits available. The job is charged once it finishes, not at submission: on the first status poll that reports completion, on the
model and a prompt and return generated images or video. List the models with GET /v1/images/models and GET /v1/videos/models; both lists are free and not rate-limited and include a predev price object per row.
Images
POST /v1/images returns generated images synchronously and is charged when the response is returned.
curl --fail-with-body https://api.pre.dev/v1/images \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "recraft/recraft-v4.1-flash", "prompt": "A lighthouse at dawn, watercolor", "n": 1, "aspect_ratio": "1:1"}'
GET /v1/images/models; each row lists the parameters it accepts in supported_parameters, and some models edit an input image rather than start from a prompt.
To edit an image or draw from one, pass it in input_references. Each item is a URL or data: URL string, or {"type": "image_url", "image_url": {"url": "..."}}.
curl --fail-with-body https://api.pre.dev/v1/images \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "google/gemini-3.1-flash-lite-image", "prompt": "The same lighthouse at night, under a sky full of stars", "input_references": ["https://example.com/lighthouse.png"]}'
credits_per_image or the other predev prices in the model row to estimate cost; the actual charge follows the call’s metered usage, like every other call.
Video
Video generation is asynchronous:POST /v1/videossubmits the job and returns it with itsidand apolling_url.GET /v1/videos/{id}reports status.polling_urlis this same URL, ending with the job’sid, so polling either one works.GET /v1/videos/{id}/contentreturns the finished video.
ID=$(curl --fail-with-body -s https://api.pre.dev/v1/videos \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "bytedance/seedance-2.0-mini", "prompt": "A paper boat drifting down a rain gutter", "duration": 4, "resolution": "480p"}' | jq -r '.id')
# poll until the status is terminal
while :; do
STATUS=$(curl --fail-with-body -s "https://api.pre.dev/v1/videos/$ID" -H "Authorization: Bearer $PREDEV_API_KEY" | jq -r '.status')
case "$STATUS" in completed|failed|cancelled|expired) break ;; esac
sleep 5
done
# then download
curl --fail-with-body "https://api.pre.dev/v1/videos/$ID/content" \
-H "Authorization: Bearer $PREDEV_API_KEY" -o video.mp4
/content download if you never polled, or by pre.dev afterwards if you stopped polling. Poll until the status is terminal (completed, failed, cancelled or expired) before reading /content. Poll and download with the job’s id from the submit response.
Jobs belong to the workspace that created them; another workspace’s job id returns 404.Authorizations
apiKeyAuthxApiKey
The workspace API key (pdk_…) from Integrations → Built-in in the pre.dev dashboard.
Headers
Attribute this call to one of the workspace's projects. An id the workspace does not own is ignored.
Body
application/json
An id from GET /v1/images/models.
Example:
"recraft/recraft-v4.1-flash"
Minimum string length:
1Upper bound on images; a model can return fewer.
Required range:
1 <= x <= 10A tier such as 2K, or exact pixels such as 1024x1024.
Examples:
"1:1"
"16:9"
"9:16"
Available options:
auto, low, medium, high, xhigh, max Available options:
png, jpeg, webp, svg Available options:
auto, transparent, opaque Reference images for image-to-image models: each a URL or data: URL string, or an image_url object.
A URL or data: URL of the image.
Stream partial images, on models whose catalog row has supports_streaming: true.
Was this page helpful?

