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"
}
}
'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"
}
}
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'}
})
};
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'
]
]),
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}")
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}")
.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}"
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/8Jd2kQ7pR1sT4uV6wX9yZ0aB2cD4eF6gH8iJ0kL2mN4",
"size": 812345,
"expires_at": "2026-09-14T10:00:31Z"
}
],
"error": null,
"missing": [],
"created_at": "2026-09-07T10:00:00Z",
"started_at": "2026-09-07T10:00:01Z",
"completed_at": "2026-09-07T10:00:31Z"
}{
"id": "0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11",
"model": "nano-banana-2",
"is_llm": false,
"status": "queued",
"input": {
"prompt": "a cat",
"aspect_ratio": "16:9",
"resolution": "2K"
},
"estimated_cost": 0.04,
"billed_cost": null,
"currency": "EUR",
"outputs": [],
"error": null,
"missing": [],
"created_at": "2026-09-07T10:00:00Z",
"started_at": null,
"completed_at": null
}{
"type": "https://fanifyai.com/docs/hub/errors#invalid_input",
"title": "Invalid input",
"status": 400,
"code": "invalid_input"
}{
"type": "https://fanifyai.com/docs/hub/errors#unauthorized",
"title": "Unauthorized",
"status": 401,
"code": "unauthorized"
}{
"type": "https://fanifyai.com/docs/hub/errors#insufficient_credits",
"title": "Insufficient credits",
"status": 402,
"code": "insufficient_credits",
"detail": "Your available balance does not cover this generation.",
"instance": "/api/v1/hub/generations"
}{
"type": "https://fanifyai.com/docs/hub/errors#model_not_found",
"title": "Model not found",
"status": 404,
"code": "model_not_found"
}{
"type": "https://fanifyai.com/docs/hub/errors#no_route_available",
"title": "No route available",
"status": 422,
"code": "no_route_available"
}{
"type": "https://fanifyai.com/docs/hub/errors#rate_limited",
"title": "Rate limit reached",
"status": 429,
"code": "rate_limited"
}{
"type": "https://fanifyai.com/docs/hub/errors#generation_in_progress",
"title": "Generation in progress",
"status": 503,
"code": "generation_in_progress"
}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"
}
}
'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"
}
}
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'}
})
};
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'
]
]),
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}")
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}")
.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}"
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/8Jd2kQ7pR1sT4uV6wX9yZ0aB2cD4eF6gH8iJ0kL2mN4",
"size": 812345,
"expires_at": "2026-09-14T10:00:31Z"
}
],
"error": null,
"missing": [],
"created_at": "2026-09-07T10:00:00Z",
"started_at": "2026-09-07T10:00:01Z",
"completed_at": "2026-09-07T10:00:31Z"
}{
"id": "0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11",
"model": "nano-banana-2",
"is_llm": false,
"status": "queued",
"input": {
"prompt": "a cat",
"aspect_ratio": "16:9",
"resolution": "2K"
},
"estimated_cost": 0.04,
"billed_cost": null,
"currency": "EUR",
"outputs": [],
"error": null,
"missing": [],
"created_at": "2026-09-07T10:00:00Z",
"started_at": null,
"completed_at": null
}{
"type": "https://fanifyai.com/docs/hub/errors#invalid_input",
"title": "Invalid input",
"status": 400,
"code": "invalid_input"
}{
"type": "https://fanifyai.com/docs/hub/errors#unauthorized",
"title": "Unauthorized",
"status": 401,
"code": "unauthorized"
}{
"type": "https://fanifyai.com/docs/hub/errors#insufficient_credits",
"title": "Insufficient credits",
"status": 402,
"code": "insufficient_credits",
"detail": "Your available balance does not cover this generation.",
"instance": "/api/v1/hub/generations"
}{
"type": "https://fanifyai.com/docs/hub/errors#model_not_found",
"title": "Model not found",
"status": 404,
"code": "model_not_found"
}{
"type": "https://fanifyai.com/docs/hub/errors#no_route_available",
"title": "No route available",
"status": 422,
"code": "no_route_available"
}{
"type": "https://fanifyai.com/docs/hub/errors#rate_limited",
"title": "Rate limit reached",
"status": 429,
"code": "rate_limited"
}{
"type": "https://fanifyai.com/docs/hub/errors#generation_in_progress",
"title": "Generation in progress",
"status": 503,
"code": "generation_in_progress"
}Autorisations
Fanify API key.
En-têtes
Idempotency key. Required for FanifyServer clients.
Réponse
Completed idempotent replay.
Options disponibles:
queued, running, succeeded, failed, canceled, awaiting_supply Options disponibles:
EUR Show child attributes
Show child attributes
Show child attributes
Show child attributes
Cette page vous a-t-elle été utile ?
