Create generation
curl --request POST \
--url https://fanifyai.com/api/v1/hub/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "nano-banana-2",
"input": {
"prompt": "a cat",
"resolution": "2K",
"aspect_ratio": "16:9"
},
"quantity": 1
}
'import requests
url = "https://fanifyai.com/api/v1/hub/generations"
payload = {
"model": "nano-banana-2",
"input": {
"prompt": "a cat",
"resolution": "2K",
"aspect_ratio": "16:9"
},
"quantity": 1
}
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: 'nano-banana-2',
input: {prompt: 'a cat', resolution: '2K', aspect_ratio: '16:9'},
quantity: 1
})
};
fetch('https://fanifyai.com/api/v1/hub/generations', 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://fanifyai.com/api/v1/hub/generations",
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' => 'nano-banana-2',
'input' => [
'prompt' => 'a cat',
'resolution' => '2K',
'aspect_ratio' => '16:9'
],
'quantity' => 1
]),
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://fanifyai.com/api/v1/hub/generations"
payload := strings.NewReader("{\n \"model\": \"nano-banana-2\",\n \"input\": {\n \"prompt\": \"a cat\",\n \"resolution\": \"2K\",\n \"aspect_ratio\": \"16:9\"\n },\n \"quantity\": 1\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://fanifyai.com/api/v1/hub/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"nano-banana-2\",\n \"input\": {\n \"prompt\": \"a cat\",\n \"resolution\": \"2K\",\n \"aspect_ratio\": \"16:9\"\n },\n \"quantity\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://fanifyai.com/api/v1/hub/generations")
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\": \"nano-banana-2\",\n \"input\": {\n \"prompt\": \"a cat\",\n \"resolution\": \"2K\",\n \"aspect_ratio\": \"16:9\"\n },\n \"quantity\": 1\n}"
response = http.request(request)
puts response.read_body{
"id": "0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11",
"model": "nano-banana-2",
"is_llm": false,
"status": "succeeded",
"input": {
"prompt": "a cat",
"aspect_ratio": "16:9",
"resolution": "2K",
"image_input": [
"https://host/cdn/a.png"
]
},
"estimated_cost": 0.04,
"billed_cost": 0.04,
"currency": "EUR",
"outputs": [
{
"index": 0,
"media_type": "image/png",
"url": "https://fanifyai.com/api/v1/hub/files/sha256/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"size": 812345,
"expires_at": "2026-09-14T10:00:31Z",
"file_name": "fanify-20260907-100000-0192f3a4.png"
}
],
"error": null,
"missing": [],
"created_at": "2026-09-07T10:00:00Z",
"started_at": "2026-09-07T10:00:01Z",
"completed_at": "2026-09-07T10:00:31Z",
"provider": "kie",
"batch_id": null,
"progress": null
}Generations
Create generation
Submits a media generation for a selected model.
POST
/
api
/
v1
/
hub
/
generations
Create generation
curl --request POST \
--url https://fanifyai.com/api/v1/hub/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "nano-banana-2",
"input": {
"prompt": "a cat",
"resolution": "2K",
"aspect_ratio": "16:9"
},
"quantity": 1
}
'import requests
url = "https://fanifyai.com/api/v1/hub/generations"
payload = {
"model": "nano-banana-2",
"input": {
"prompt": "a cat",
"resolution": "2K",
"aspect_ratio": "16:9"
},
"quantity": 1
}
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: 'nano-banana-2',
input: {prompt: 'a cat', resolution: '2K', aspect_ratio: '16:9'},
quantity: 1
})
};
fetch('https://fanifyai.com/api/v1/hub/generations', 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://fanifyai.com/api/v1/hub/generations",
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' => 'nano-banana-2',
'input' => [
'prompt' => 'a cat',
'resolution' => '2K',
'aspect_ratio' => '16:9'
],
'quantity' => 1
]),
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://fanifyai.com/api/v1/hub/generations"
payload := strings.NewReader("{\n \"model\": \"nano-banana-2\",\n \"input\": {\n \"prompt\": \"a cat\",\n \"resolution\": \"2K\",\n \"aspect_ratio\": \"16:9\"\n },\n \"quantity\": 1\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://fanifyai.com/api/v1/hub/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"nano-banana-2\",\n \"input\": {\n \"prompt\": \"a cat\",\n \"resolution\": \"2K\",\n \"aspect_ratio\": \"16:9\"\n },\n \"quantity\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://fanifyai.com/api/v1/hub/generations")
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\": \"nano-banana-2\",\n \"input\": {\n \"prompt\": \"a cat\",\n \"resolution\": \"2K\",\n \"aspect_ratio\": \"16:9\"\n },\n \"quantity\": 1\n}"
response = http.request(request)
puts response.read_body{
"id": "0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11",
"model": "nano-banana-2",
"is_llm": false,
"status": "succeeded",
"input": {
"prompt": "a cat",
"aspect_ratio": "16:9",
"resolution": "2K",
"image_input": [
"https://host/cdn/a.png"
]
},
"estimated_cost": 0.04,
"billed_cost": 0.04,
"currency": "EUR",
"outputs": [
{
"index": 0,
"media_type": "image/png",
"url": "https://fanifyai.com/api/v1/hub/files/sha256/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"size": 812345,
"expires_at": "2026-09-14T10:00:31Z",
"file_name": "fanify-20260907-100000-0192f3a4.png"
}
],
"error": null,
"missing": [],
"created_at": "2026-09-07T10:00:00Z",
"started_at": "2026-09-07T10:00:01Z",
"completed_at": "2026-09-07T10:00:31Z",
"provider": "kie",
"batch_id": null,
"progress": null
}Corps
application/json
Generation request. quantity (1..100, default 1) admits a batch all-or-nothing (D44). Reference a file input as sha256: (see POST /api/v1/hub/files); a hash the Hub does not have answers 422 missing_resource listing missing[].sha256: upload those files, then resubmit with the same Idempotency-Key. Any other URL is forwarded to the provider as is, except on a model priced on the duration of an input file: its file must be uploaded and referenced as sha256:, else 422 input_duration_unavailable.
Réponse
Completed idempotent replay (a batch replays as {batch_id, generations[]}).
Cette page vous a-t-elle été utile ?
