cURL
curl --no-buffer \
--request POST \
--url 'https://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent?key=YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contents": [{
"role": "user",
"parts": [{"text": "Create a green data center illustration."}]
}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {"aspectRatio": "16:9", "imageSize": "1K"}
}
}'
import requests
url = "https://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent"
payload = {
"contents": [
{
"parts": [
{
"text": "<string>",
"fileData": {}
}
],
"role": "user"
}
],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {
"aspectRatio": "16:9",
"imageSize": "1K"
},
"thinkingConfig": {}
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [{parts: [{text: '<string>', fileData: {}}], role: 'user'}],
generationConfig: {
responseModalities: ['TEXT', 'IMAGE'],
imageConfig: {aspectRatio: '16:9', imageSize: '1K'},
thinkingConfig: {}
}
})
};
fetch('https://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent', 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://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent",
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([
'contents' => [
[
'parts' => [
[
'text' => '<string>',
'fileData' => [
]
]
],
'role' => 'user'
]
],
'generationConfig' => [
'responseModalities' => [
'TEXT',
'IMAGE'
],
'imageConfig' => [
'aspectRatio' => '16:9',
'imageSize' => '1K'
],
'thinkingConfig' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"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://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"fileData\": {}\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"TEXT\",\n \"IMAGE\"\n ],\n \"imageConfig\": {\n \"aspectRatio\": \"16:9\",\n \"imageSize\": \"1K\"\n },\n \"thinkingConfig\": {}\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"fileData\": {}\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"TEXT\",\n \"IMAGE\"\n ],\n \"imageConfig\": {\n \"aspectRatio\": \"16:9\",\n \"imageSize\": \"1K\"\n },\n \"thinkingConfig\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"fileData\": {}\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"TEXT\",\n \"IMAGE\"\n ],\n \"imageConfig\": {\n \"aspectRatio\": \"16:9\",\n \"imageSize\": \"1K\"\n },\n \"thinkingConfig\": {}\n }\n}"
response = http.request(request)
puts response.read_bodydata: {"candidates":[{"content":{"role":"model","parts":[{"text":"..."}]}}]}
data: {"candidates":[{"content":{"role":"model","parts":[{"inlineData":{"mimeType":"image/png","data":"<base64>"}}]}}]}
data: {"usageMetadata":{"promptTokenCount":24,"candidatesTokenCount":1024,"totalTokenCount":1048}}
{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}Google
gemini-nano-banana-2.1-stream
Sends a GenerateContent request and returns a Server-Sent Events stream containing GenerateContentResponse chunks.
POST
/
v1beta
/
models
/
gemini-nano-banana-2.1:streamGenerateContent
cURL
curl --no-buffer \
--request POST \
--url 'https://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent?key=YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contents": [{
"role": "user",
"parts": [{"text": "Create a green data center illustration."}]
}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {"aspectRatio": "16:9", "imageSize": "1K"}
}
}'
import requests
url = "https://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent"
payload = {
"contents": [
{
"parts": [
{
"text": "<string>",
"fileData": {}
}
],
"role": "user"
}
],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {
"aspectRatio": "16:9",
"imageSize": "1K"
},
"thinkingConfig": {}
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [{parts: [{text: '<string>', fileData: {}}], role: 'user'}],
generationConfig: {
responseModalities: ['TEXT', 'IMAGE'],
imageConfig: {aspectRatio: '16:9', imageSize: '1K'},
thinkingConfig: {}
}
})
};
fetch('https://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent', 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://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent",
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([
'contents' => [
[
'parts' => [
[
'text' => '<string>',
'fileData' => [
]
]
],
'role' => 'user'
]
],
'generationConfig' => [
'responseModalities' => [
'TEXT',
'IMAGE'
],
'imageConfig' => [
'aspectRatio' => '16:9',
'imageSize' => '1K'
],
'thinkingConfig' => [
]
]
]),
CURLOPT_HTTPHEADER => [
"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://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"fileData\": {}\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"TEXT\",\n \"IMAGE\"\n ],\n \"imageConfig\": {\n \"aspectRatio\": \"16:9\",\n \"imageSize\": \"1K\"\n },\n \"thinkingConfig\": {}\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"fileData\": {}\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"TEXT\",\n \"IMAGE\"\n ],\n \"imageConfig\": {\n \"aspectRatio\": \"16:9\",\n \"imageSize\": \"1K\"\n },\n \"thinkingConfig\": {}\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.anyfast.ai/v1beta/models/gemini-nano-banana-2.1:streamGenerateContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"fileData\": {}\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"TEXT\",\n \"IMAGE\"\n ],\n \"imageConfig\": {\n \"aspectRatio\": \"16:9\",\n \"imageSize\": \"1K\"\n },\n \"thinkingConfig\": {}\n }\n}"
response = http.request(request)
puts response.read_bodydata: {"candidates":[{"content":{"role":"model","parts":[{"text":"..."}]}}]}
data: {"candidates":[{"content":{"role":"model","parts":[{"inlineData":{"mimeType":"image/png","data":"<base64>"}}]}}]}
data: {"usageMetadata":{"promptTokenCount":24,"candidatesTokenCount":1024,"totalTokenCount":1048}}
{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}Query Parameters
AnyFast API key.
Set to sse to explicitly request Server-Sent Events mode.
Available options:
sse Body
application/json
Response
Server-Sent Events stream. Each data event contains one JSON GenerateContentResponse chunk.
Newline-delimited SSE events with JSON response chunks.
Was this page helpful?