cURL
curl --request POST \
--url 'https://www.anyfast.ai/v1beta/models/gemini-2.0-flash:generateContent?key=<token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Change the background to blue sky with clouds"
},
{
"inline_data": {
"mime_type": "image/png",
"data": "BASE64_IMAGE_DATA"
}
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
]
}
}
'import requests
url = "https://www.anyfast.ai/v1beta/models/gemini-2.0-flash:generateContent"
payload = {
"contents": [
{
"role": "user",
"parts": [{ "text": "Change the background to blue sky with clouds" }, { "inline_data": {
"mime_type": "image/png",
"data": "BASE64_IMAGE_DATA"
} }]
}
],
"generationConfig": { "responseModalities": ["IMAGE"] }
}
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: [
{
role: 'user',
parts: [
{text: 'Change the background to blue sky with clouds'},
{inline_data: {mime_type: 'image/png', data: 'BASE64_IMAGE_DATA'}}
]
}
],
generationConfig: {responseModalities: ['IMAGE']}
})
};
fetch('https://www.anyfast.ai/v1beta/models/gemini-2.0-flash:generateContent', 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-2.0-flash:generateContent",
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' => [
[
'role' => 'user',
'parts' => [
[
'text' => 'Change the background to blue sky with clouds'
],
[
'inline_data' => [
'mime_type' => 'image/png',
'data' => 'BASE64_IMAGE_DATA'
]
]
]
]
],
'generationConfig' => [
'responseModalities' => [
'IMAGE'
]
]
]),
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-2.0-flash:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Change the background to blue sky with clouds\"\n },\n {\n \"inline_data\": {\n \"mime_type\": \"image/png\",\n \"data\": \"BASE64_IMAGE_DATA\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"IMAGE\"\n ]\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-2.0-flash:generateContent")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Change the background to blue sky with clouds\"\n },\n {\n \"inline_data\": {\n \"mime_type\": \"image/png\",\n \"data\": \"BASE64_IMAGE_DATA\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"IMAGE\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.anyfast.ai/v1beta/models/gemini-2.0-flash:generateContent")
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 \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Change the background to blue sky with clouds\"\n },\n {\n \"inline_data\": {\n \"mime_type\": \"image/png\",\n \"data\": \"BASE64_IMAGE_DATA\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"IMAGE\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"content": {
"parts": [
{
"inline_data": {
"mime_type": "image/png",
"data": "iVBORw0KGgo..."
},
"text": "<string>"
}
],
"role": "model"
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}Google
gemini-2.0-flash
Edit images using Gemini model.
POST
/
v1beta
/
models
/
gemini-2.0-flash:generateContent
cURL
curl --request POST \
--url 'https://www.anyfast.ai/v1beta/models/gemini-2.0-flash:generateContent?key=<token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Change the background to blue sky with clouds"
},
{
"inline_data": {
"mime_type": "image/png",
"data": "BASE64_IMAGE_DATA"
}
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
]
}
}
'import requests
url = "https://www.anyfast.ai/v1beta/models/gemini-2.0-flash:generateContent"
payload = {
"contents": [
{
"role": "user",
"parts": [{ "text": "Change the background to blue sky with clouds" }, { "inline_data": {
"mime_type": "image/png",
"data": "BASE64_IMAGE_DATA"
} }]
}
],
"generationConfig": { "responseModalities": ["IMAGE"] }
}
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: [
{
role: 'user',
parts: [
{text: 'Change the background to blue sky with clouds'},
{inline_data: {mime_type: 'image/png', data: 'BASE64_IMAGE_DATA'}}
]
}
],
generationConfig: {responseModalities: ['IMAGE']}
})
};
fetch('https://www.anyfast.ai/v1beta/models/gemini-2.0-flash:generateContent', 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-2.0-flash:generateContent",
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' => [
[
'role' => 'user',
'parts' => [
[
'text' => 'Change the background to blue sky with clouds'
],
[
'inline_data' => [
'mime_type' => 'image/png',
'data' => 'BASE64_IMAGE_DATA'
]
]
]
]
],
'generationConfig' => [
'responseModalities' => [
'IMAGE'
]
]
]),
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-2.0-flash:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Change the background to blue sky with clouds\"\n },\n {\n \"inline_data\": {\n \"mime_type\": \"image/png\",\n \"data\": \"BASE64_IMAGE_DATA\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"IMAGE\"\n ]\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-2.0-flash:generateContent")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Change the background to blue sky with clouds\"\n },\n {\n \"inline_data\": {\n \"mime_type\": \"image/png\",\n \"data\": \"BASE64_IMAGE_DATA\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"IMAGE\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.anyfast.ai/v1beta/models/gemini-2.0-flash:generateContent")
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 \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Change the background to blue sky with clouds\"\n },\n {\n \"inline_data\": {\n \"mime_type\": \"image/png\",\n \"data\": \"BASE64_IMAGE_DATA\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"responseModalities\": [\n \"IMAGE\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"content": {
"parts": [
{
"inline_data": {
"mime_type": "image/png",
"data": "iVBORw0KGgo..."
},
"text": "<string>"
}
],
"role": "model"
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}Query Parameters
API Key
Body
application/json
Array of contents with editing instructions and source images.
Show child attributes
Show child attributes
Example:
[
{
"role": "user",
"parts": [
{
"text": "Change the background to blue sky with clouds"
},
{
"inline_data": {
"mime_type": "image/png",
"data": "BASE64_IMAGE_DATA"
}
}
]
}
]
Show child attributes
Show child attributes
Was this page helpful?
⌘I