# Le champ model peut valoir "gemini-3.1-flash-image-preview" ou son alias compatible "nano-banana-2-ext"curl --request POST \ --url https://api.apimart.ai/v1/images/generations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "gemini-3.1-flash-image-preview", "prompt": "Cyberpunk cityscape at night with neon lights", "size": "16:9", "resolution": "2K", "n": 1 }'
import Foundationlet url = URL(string: "https://api.apimart.ai/v1/images/generations")!let payload: [String: Any] = [ "model": "gemini-3.1-flash-image-preview", "prompt": "Cyberpunk cityscape at night with neon lights", "size": "16:9", "resolution": "2K", "n": 1]var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")request.httpBody = try? JSONSerialization.data(withJSONObject: payload)let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } if let data = data, let responseString = String(data: data, encoding: .utf8) { print(responseString) }}task.resume()
using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;class Program{ static async Task Main(string[] args) { var url = "https://api.apimart.ai/v1/images/generations"; var payload = @"{ ""model"": ""gemini-3.1-flash-image-preview"", ""prompt"": ""Cyberpunk cityscape at night with neon lights"", ""size"": ""16:9"", ""resolution"": ""2K"", ""n"": 1 }"; using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>"); var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }}
(* Requires cohttp and yojson libraries *)open Lwtopen Cohttpopen Cohttp_lwt_unixlet url = "https://api.apimart.ai/v1/images/generations"let payload = {|{ "model": "gemini-3.1-flash-image-preview", "prompt": "Cyberpunk cityscape at night with neon lights", "size": "16:9", "resolution": "2K", "n": 1}|}let () = let headers = Header.init () |> fun h -> Header.add h "Authorization" "Bearer <token>" |> fun h -> Header.add h "Content-Type" "application/json" in let body = Cohttp_lwt.Body.of_string payload in let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) -> body |> Cohttp_lwt.Body.to_string >|= fun body_str -> print_endline body_str in Lwt_main.run response
import 'dart:convert';import 'package:http/http.dart' as http;void main() async { final url = Uri.parse('https://api.apimart.ai/v1/images/generations'); final payload = { 'model': 'gemini-3.1-flash-image-preview', 'prompt': 'Cyberpunk cityscape at night with neon lights', 'size': '16:9', 'resolution': '2K', 'n': 1 }; final response = await http.post( url, headers: { 'Authorization': 'Bearer <token>', 'Content-Type': 'application/json', }, body: jsonEncode(payload), ); print(response.body);}
library(httr)library(jsonlite)url <- "https://api.apimart.ai/v1/images/generations"payload <- list( model = "gemini-3.1-flash-image-preview", prompt = "Cyberpunk cityscape at night with neon lights", size = "16:9", resolution = "2K", n = 1)response <- POST( url, add_headers( Authorization = "Bearer <token>", `Content-Type` = "application/json" ), body = toJSON(payload, auto_unbox = TRUE), encode = "raw")cat(content(response, "text"))
{ "error": { "code": 500, "message": "Internal server error. Please try again later", "type": "server_error" }}
{ "error": { "code": 502, "message": "Bad gateway. The server is temporarily unavailable", "type": "bad_gateway" }}
Nano banana2
Nano banana2 Génération d'images
Prend en charge la génération texte-vers-image et image-vers-image, sortie jusqu’à la résolution 4K
Jusqu’à 14 images de référence pour la cohérence de style/personnage
Prend en charge des ratios d’aspect extrêmes (1:4, 4:1, 1:8, 8:1)
Amélioration intégrée via la recherche Google pour une génération d’images plus réaliste
POST
/
v1
/
images
/
generations
# Le champ model peut valoir "gemini-3.1-flash-image-preview" ou son alias compatible "nano-banana-2-ext"curl --request POST \ --url https://api.apimart.ai/v1/images/generations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "gemini-3.1-flash-image-preview", "prompt": "Cyberpunk cityscape at night with neon lights", "size": "16:9", "resolution": "2K", "n": 1 }'
import Foundationlet url = URL(string: "https://api.apimart.ai/v1/images/generations")!let payload: [String: Any] = [ "model": "gemini-3.1-flash-image-preview", "prompt": "Cyberpunk cityscape at night with neon lights", "size": "16:9", "resolution": "2K", "n": 1]var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")request.httpBody = try? JSONSerialization.data(withJSONObject: payload)let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } if let data = data, let responseString = String(data: data, encoding: .utf8) { print(responseString) }}task.resume()
using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;class Program{ static async Task Main(string[] args) { var url = "https://api.apimart.ai/v1/images/generations"; var payload = @"{ ""model"": ""gemini-3.1-flash-image-preview"", ""prompt"": ""Cyberpunk cityscape at night with neon lights"", ""size"": ""16:9"", ""resolution"": ""2K"", ""n"": 1 }"; using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>"); var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }}
(* Requires cohttp and yojson libraries *)open Lwtopen Cohttpopen Cohttp_lwt_unixlet url = "https://api.apimart.ai/v1/images/generations"let payload = {|{ "model": "gemini-3.1-flash-image-preview", "prompt": "Cyberpunk cityscape at night with neon lights", "size": "16:9", "resolution": "2K", "n": 1}|}let () = let headers = Header.init () |> fun h -> Header.add h "Authorization" "Bearer <token>" |> fun h -> Header.add h "Content-Type" "application/json" in let body = Cohttp_lwt.Body.of_string payload in let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) -> body |> Cohttp_lwt.Body.to_string >|= fun body_str -> print_endline body_str in Lwt_main.run response
import 'dart:convert';import 'package:http/http.dart' as http;void main() async { final url = Uri.parse('https://api.apimart.ai/v1/images/generations'); final payload = { 'model': 'gemini-3.1-flash-image-preview', 'prompt': 'Cyberpunk cityscape at night with neon lights', 'size': '16:9', 'resolution': '2K', 'n': 1 }; final response = await http.post( url, headers: { 'Authorization': 'Bearer <token>', 'Content-Type': 'application/json', }, body: jsonEncode(payload), ); print(response.body);}
library(httr)library(jsonlite)url <- "https://api.apimart.ai/v1/images/generations"payload <- list( model = "gemini-3.1-flash-image-preview", prompt = "Cyberpunk cityscape at night with neon lights", size = "16:9", resolution = "2K", n = 1)response <- POST( url, add_headers( Authorization = "Bearer <token>", `Content-Type` = "application/json" ), body = toJSON(payload, auto_unbox = TRUE), encode = "raw")cat(content(response, "text"))
{ "error": { "code": 500, "message": "Internal server error. Please try again later", "type": "server_error" }}
{ "error": { "code": 502, "message": "Bad gateway. The server is temporarily unavailable", "type": "bad_gateway" }}
Alias de modèle compatible : cette API prend également en charge l’alias nano-banana-2-ext, équivalent à gemini-3.1-flash-image-preview ; les deux sont interchangeables et produisent des résultats identiques.
# Le champ model peut valoir "gemini-3.1-flash-image-preview" ou son alias compatible "nano-banana-2-ext"curl --request POST \ --url https://api.apimart.ai/v1/images/generations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "gemini-3.1-flash-image-preview", "prompt": "Cyberpunk cityscape at night with neon lights", "size": "16:9", "resolution": "2K", "n": 1 }'
import Foundationlet url = URL(string: "https://api.apimart.ai/v1/images/generations")!let payload: [String: Any] = [ "model": "gemini-3.1-flash-image-preview", "prompt": "Cyberpunk cityscape at night with neon lights", "size": "16:9", "resolution": "2K", "n": 1]var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")request.httpBody = try? JSONSerialization.data(withJSONObject: payload)let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } if let data = data, let responseString = String(data: data, encoding: .utf8) { print(responseString) }}task.resume()
using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;class Program{ static async Task Main(string[] args) { var url = "https://api.apimart.ai/v1/images/generations"; var payload = @"{ ""model"": ""gemini-3.1-flash-image-preview"", ""prompt"": ""Cyberpunk cityscape at night with neon lights"", ""size"": ""16:9"", ""resolution"": ""2K"", ""n"": 1 }"; using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>"); var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }}
(* Requires cohttp and yojson libraries *)open Lwtopen Cohttpopen Cohttp_lwt_unixlet url = "https://api.apimart.ai/v1/images/generations"let payload = {|{ "model": "gemini-3.1-flash-image-preview", "prompt": "Cyberpunk cityscape at night with neon lights", "size": "16:9", "resolution": "2K", "n": 1}|}let () = let headers = Header.init () |> fun h -> Header.add h "Authorization" "Bearer <token>" |> fun h -> Header.add h "Content-Type" "application/json" in let body = Cohttp_lwt.Body.of_string payload in let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) -> body |> Cohttp_lwt.Body.to_string >|= fun body_str -> print_endline body_str in Lwt_main.run response
import 'dart:convert';import 'package:http/http.dart' as http;void main() async { final url = Uri.parse('https://api.apimart.ai/v1/images/generations'); final payload = { 'model': 'gemini-3.1-flash-image-preview', 'prompt': 'Cyberpunk cityscape at night with neon lights', 'size': '16:9', 'resolution': '2K', 'n': 1 }; final response = await http.post( url, headers: { 'Authorization': 'Bearer <token>', 'Content-Type': 'application/json', }, body: jsonEncode(payload), ); print(response.body);}
library(httr)library(jsonlite)url <- "https://api.apimart.ai/v1/images/generations"payload <- list( model = "gemini-3.1-flash-image-preview", prompt = "Cyberpunk cityscape at night with neon lights", size = "16:9", resolution = "2K", n = 1)response <- POST( url, add_headers( Authorization = "Bearer <token>", `Content-Type` = "application/json" ), body = toJSON(payload, auto_unbox = TRUE), encode = "raw")cat(content(response, "text"))
Tous les points de terminaison de l’API nécessitent une authentification Bearer TokenObtenir votre clé API :Rendez-vous sur la page de gestion des clés API pour obtenir votre clé APIAjoutez-la à l’en-tête de la requête :
Nom du modèle de génération d’imagesModèles pris en charge :
gemini-3.1-flash-image-preview — Version standard (alias compatible nano-banana-2-ext)
gemini-3.1-flash-image-preview-official — Version officielle (alias compatible nano-banana-2)
Exemple : "gemini-3.1-flash-image-preview" ou "gemini-3.1-flash-image-preview-official"
Pour assurer la compatibilité avec les anciens appels, les alias nano-banana-2-ext (correspondant à gemini-3.1-flash-image-preview) et nano-banana-2 (correspondant à gemini-3.1-flash-image-preview-official) restent utilisables normalement.
Pour la génération texte-vers-image, lorsque size vaut auto, la valeur par défaut est 1:1 ou 16:9 ; pour la génération image-vers-image, le ratio d’aspect suit la réponse de la source en amont. Nous vous recommandons de spécifier explicitement un ratio d’aspect.
Activer l’amélioration via la recherche textuelle Google
true : Le modèle recherchera des informations textuelles sur le Web pour aider à la génération d’images, adapté aux scénarios nécessitant des informations réelles
Activer l’amélioration via la recherche d’images Google
true : En plus de la recherche textuelle, des images de référence seront également recherchées pour aider à la génération, adapté aux scénarios nécessitant des références visuelles
false : Désactivé (par défaut)
Note : Doit être utilisé conjointement avec google_search: true