🎨 ChatGPT 最新生图 gpt-image-2-all 已上线 | Now Live:$0.03/张图,对话式端点提示词遵循最佳!详情 Details
curl --request POST \
--url https://api.apiyi.com/v1beta/models/gemini-3-pro-image-preview:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{
"text": "Please blur the background to highlight the person in the foreground"
},
{
"inlineData": {
"mimeType": "image/jpeg",
"data": "BASE64_ENCODED_IMAGE_DATA"
}
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"imageConfig": {
"aspectRatio": "16:9",
"imageSize": "2K"
}
}
}
'{
"candidates": [
{
"content": {
"parts": [
{
"inlineData": {
"mimeType": "image/png",
"data": "<string>"
}
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 10,
"candidatesTokenCount": 258
}
}Nano Banana Pro image editing API reference and interactive playground — provide an image + instruction to generate an edited result
curl --request POST \
--url https://api.apiyi.com/v1beta/models/gemini-3-pro-image-preview:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{
"text": "Please blur the background to highlight the person in the foreground"
},
{
"inlineData": {
"mimeType": "image/jpeg",
"data": "BASE64_ENCODED_IMAGE_DATA"
}
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"imageConfig": {
"aspectRatio": "16:9",
"imageSize": "2K"
}
}
}
'{
"candidates": [
{
"content": {
"parts": [
{
"inlineData": {
"mimeType": "image/png",
"data": "<string>"
}
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 10,
"candidatesTokenCount": 258
}
}Documentation Index
Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
Use this file to discover all available pages before exploring further.
Bearer sk-xxx) to send test requests with one click.inlineData.data fieldThis endpoint uses JSON format (not multipart file upload), so the Playground cannot directly select local files. You need to convert your image to a Base64 string first, then paste it into the data input.One-line command: convert + copy to clipboard:# macOS
base64 -i your-image.jpg | tr -d '\n' | pbcopy
# Linux
base64 -w0 your-image.jpg | xclip -selection clipboard
# Windows PowerShell
[Convert]::ToBase64String([IO.File]::ReadAllBytes("your-image.jpg")) | Set-Clipboard
Cmd+V / Ctrl+V paste into the data field in the Playground. Also remember to set mimeType to the matching image/jpeg or image/png.Recommendation: Use small images (less than 200KB) for testing to avoid browser lag from long base64 strings. For frequent image editing tests, use the code examples below to run locally instead.import requests
import base64
API_KEY = "sk-your-api-key"
# Read the image to edit
with open("input.jpg", "rb") as f:
image_b64 = base64.b64encode(f.read()).decode()
response = requests.post(
"https://api.apiyi.com/v1beta/models/gemini-3-pro-image-preview:generateContent",
headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
json={
"contents": [{
"parts": [
{"text": "Please blur the background to highlight the person in the foreground"},
{"inlineData": {"mimeType": "image/jpeg", "data": image_b64}}
]
}],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": {"aspectRatio": "16:9", "imageSize": "2K"}
}
},
timeout=300
).json()
img_data = response["candidates"][0]["content"]["parts"][0]["inlineData"]["data"]
with open("edited.png", 'wb') as f:
f.write(base64.b64decode(img_data))
print("Edited image saved to edited.png")
import fs from "fs";
const API_KEY = "sk-your-api-key";
const imageB64 = fs.readFileSync("input.jpg").toString("base64");
const response = await fetch(
"https://api.apiyi.com/v1beta/models/gemini-3-pro-image-preview:generateContent",
{
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
contents: [{
parts: [
{ text: "Please blur the background to highlight the person in the foreground" },
{ inlineData: { mimeType: "image/jpeg", data: imageB64 } }
]
}],
generationConfig: {
responseModalities: ["IMAGE"],
imageConfig: { aspectRatio: "16:9", imageSize: "2K" }
}
})
}
);
const data = await response.json();
const imgBase64 = data.candidates[0].content.parts[0].inlineData.data;
fs.writeFileSync("edited.png", Buffer.from(imgBase64, "base64"));
# Note: convert image to base64 first
# IMAGE_B64=$(base64 -i input.jpg | tr -d '\n')
curl -X POST "https://api.apiyi.com/v1beta/models/gemini-3-pro-image-preview:generateContent" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts": [
{"text": "Please blur the background to highlight the person in the foreground"},
{"inlineData": {"mimeType": "image/jpeg", "data": "'"$IMAGE_B64"'"}}
]
}],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": {"aspectRatio": "16:9", "imageSize": "2K"}
}
}'
| Parameter | Type | Required | Description |
|---|---|---|---|
contents[].parts[].text | string | Yes | Edit instruction |
contents[].parts[].inlineData.mimeType | string | Yes | image/jpeg or image/png |
contents[].parts[].inlineData.data | string | Yes | Base64-encoded image |
generationConfig.responseModalities | array | Yes | Usually ["IMAGE"] |
generationConfig.imageConfig.aspectRatio | string | No | 10 ratios, default 1:1 |
generationConfig.imageConfig.imageSize | string | No | 1K / 2K / 4K, default 1K |
API Key from APIYI Console