Edit a prior generation
curl --request POST \
--url https://app.dafty.ai/api/v1/images/edit \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"imageId": "3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f",
"prompt": "Change the background to deep navy"
}
'import requests
url = "https://app.dafty.ai/api/v1/images/edit"
payload = {
"imageId": "3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f",
"prompt": "Change the background to deep navy"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
imageId: '3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f',
prompt: 'Change the background to deep navy'
})
};
fetch('https://app.dafty.ai/api/v1/images/edit', 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://app.dafty.ai/api/v1/images/edit",
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([
'imageId' => '3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f',
'prompt' => 'Change the background to deep navy'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://app.dafty.ai/api/v1/images/edit"
payload := strings.NewReader("{\n \"imageId\": \"3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f\",\n \"prompt\": \"Change the background to deep navy\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://app.dafty.ai/api/v1/images/edit")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"imageId\": \"3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f\",\n \"prompt\": \"Change the background to deep navy\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.dafty.ai/api/v1/images/edit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"imageId\": \"3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f\",\n \"prompt\": \"Change the background to deep navy\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"result": {
"images": [
{
"id": "<string>",
"url": "<string>",
"width": 0,
"height": 0
}
],
"video": {
"id": "<string>",
"url": "<string>",
"durationSeconds": 0,
"thumbnailUrl": "<string>",
"width": 0,
"height": 0
},
"style": {
"id": "<string>"
}
},
"error": {
"message": "<string>"
}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"details": {}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"details": {}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"details": {}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"details": {}
}
}Images
Edit a prior generation
image is the job id of a completed image you own; the edit replays that job’s edit chain.
POST
/
images
/
edit
Edit a prior generation
curl --request POST \
--url https://app.dafty.ai/api/v1/images/edit \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"imageId": "3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f",
"prompt": "Change the background to deep navy"
}
'import requests
url = "https://app.dafty.ai/api/v1/images/edit"
payload = {
"imageId": "3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f",
"prompt": "Change the background to deep navy"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
imageId: '3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f',
prompt: 'Change the background to deep navy'
})
};
fetch('https://app.dafty.ai/api/v1/images/edit', 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://app.dafty.ai/api/v1/images/edit",
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([
'imageId' => '3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f',
'prompt' => 'Change the background to deep navy'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://app.dafty.ai/api/v1/images/edit"
payload := strings.NewReader("{\n \"imageId\": \"3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f\",\n \"prompt\": \"Change the background to deep navy\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://app.dafty.ai/api/v1/images/edit")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"imageId\": \"3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f\",\n \"prompt\": \"Change the background to deep navy\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.dafty.ai/api/v1/images/edit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"imageId\": \"3f9a4c2e-7b1d-4e8a-9c3f-2a1b0c9d8e7f\",\n \"prompt\": \"Change the background to deep navy\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"result": {
"images": [
{
"id": "<string>",
"url": "<string>",
"width": 0,
"height": 0
}
],
"video": {
"id": "<string>",
"url": "<string>",
"durationSeconds": 0,
"thumbnailUrl": "<string>",
"width": 0,
"height": 0
},
"style": {
"id": "<string>"
}
},
"error": {
"message": "<string>"
}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"details": {}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"details": {}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"details": {}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"details": {}
}
}Authorizations
apiKeybearerAuth
Headers
Optional unique key (≤255 chars) that makes this create idempotent: a retry with the same key returns the original job rather than starting a new one. Scoped to your API key; retained ~24h.
Maximum string length:
255Body
application/json
The id of a prior generation (job) to edit, resize, or upscale.
Pattern:
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$The text prompt. Up to 2000 characters.
Required string length:
1 - 2000Up to 4 reference images to guide the generation.
Maximum array length:
4A reference image: either an https URL we ingest (SSRF-guarded, then re-hosted) or the id/url of one of your uploads or prior generations. Resolved server-side to our storage.
Required string length:
1 - 2048Response
Accepted
Show child attributes
Show child attributes
⌘I

