模型

Google: Nano Banana 2 Lite (Gemini 3.1 Flash Lite Image)

Markdown · JSON

Google: Nano Banana 2 Lite (Gemini 3.1 Flash Lite Image)

Nano Banana 2 Lite 亦名 Gemini 3.1 Flash Lite Image,是 Google 用於快速視覺探索的圖像模型。公開設定接收文字與圖像,回傳圖像或文字,支援結合視覺參考素材的圖像需求。

關於模型

此說明介紹模型的能力。Ailoot 可用的輸入、輸出與選項,依所選方法列於下方。

Nano Banana 2 Lite 是 Google 的 Gemini 3.1 Flash Lite Image 模型,用於快速視覺探索及文字生成圖像。公開設定接收文字與圖像輸入,可回傳圖像及文字,讓書面需求與視覺來源素材成為同一創作請求的一部分。

明確說明視覺結果需求

描述圖像主體、構圖、媒材及使用目的地。產品插圖可指定物件、視角、背景,以及周圍版面需要的空間。場景可指明環境、主要動作及建立氛圍的細節。加入裝飾細節前,先清楚確定構成圖像的少數關鍵關係。

可見文字重要時,請提供確切文字及其層級。說明哪一行應最醒目,以及它與主要主體的關係。以實際使用尺寸檢查回傳圖像中的拼字、標籤及間距。視覺概念的內容可依需求核對時,才成為實用成果。

指明圖像輸入的角色

告訴模型提供的圖像對請求有何貢獻。它可確立主體、可見配置,或新視覺應納入考量的素材。請指出重要細節,避免參考圖成為需求中未解釋的部分。比較所需變更或視覺方向時,將來源圖像與回傳結果一併保留。

將選定圖像帶入下一步

檢查實際成果是否符合預期主體、取景、重要文字及元素關係。將成功的需求、參考素材及選定結果一起保存。製作系列時,後續請求應保留重複主體與視覺術語,並在合併成完成版面前比較所得圖像的連續性。

實用交付成果是此確切 Lite 設定回傳的視覺素材或附帶文字。匯出尺寸、檔案格式及接受的控制取決於使用的圖像介面;準備放置或後續編輯時,請隨成果保留其實際屬性。

實用任務

實用任務

英文技術範例

Explore a product illustration

Create a clean editorial illustration of a reusable steel lunchbox, lid open at a three-quarter angle, with two compartments visible. Use soft daylight, a warm off-white background and restrained sage accents. Place the lunchbox in the lower-right area with generous empty space at upper left for a website heading. Include no lettering or logos.

預期結果

An image concept showing the open two-compartment lunchbox, warm background and clear upper-left layout space.

檢查結果

Inspect the actual image for two visible compartments, the requested placement and absence of lettering or logos.
Ailoot · 圖片 POST /v1/images/generations gemini-3.1-flash-lite-image

gemini-3.1-flash-lite-image

Google /gemini-3.1-flash-lite-image

入門

Nano Banana 2 Lite 亦名 Gemini 3.1 Flash Lite Image,是 Google 用於快速視覺探索的圖像模型。公開設定接收文字與圖像,回傳圖像或文字,支援結合視覺參考素材的圖像需求。

接受的輸入
文字
結果
圖片

Ailoot 可用 · 輸入與方法

Ailoot · 圖片 POST /v1/images/generations
輸入
text
輸出
image
上下文
65,536 tokens
輸出上限
4,096 tokens
輸出格式
圖片檔案
欄位類型要求值與限制預設值
欄位model類型string要求必填值與限制
gemini-3.1-flash-lite-image
預設值—
欄位prompt類型string要求必填值與限制
長度下限: 1
預設值—
欄位n類型integer要求選填值與限制
最小值: 1
預設值1
欄位response_format類型string要求選填值與限制
url, b64_json
預設值—
欄位stream類型boolean要求選填值與限制預設值false
欄位size類型string要求選填值與限制
依模型而定
預設值—
欄位quality類型string要求選填值與限制
依模型而定
預設值—
欄位background類型string要求選填值與限制
依模型而定
預設值—
欄位output_format類型string要求選填值與限制
依模型而定
預設值—
欄位output_compression類型integer要求選填值與限制
依模型而定
預設值—
欄位moderation類型string要求選填值與限制
依模型而定
預設值—
欄位input_fidelity類型string要求選填值與限制
依模型而定
預設值—
欄位style類型string要求選填值與限制
依模型而定
預設值—
欄位partial_images類型integer要求選填值與限制
依模型而定
預設值—
輸入素材組合

文字生成圖片 · 必填: prompt

方法參數與生命週期
參數規格
參數material_types規格text
參數required規格model, prompt
參數optional_controls規格null
參數content_type規格application/json

生命週期: synchronous_result_then_owned_library

GET /v1/media/tasks/{task_id} · 實際回傳的 task_id 或媒體庫紀錄

GET /v1/media/assets/{asset_id}/content

GET /v1/media/assets

GET /v1/media/assets/{asset_id}

方法結構與 ID 均為精確值;供應商能力與准入狀態分開。

方案

Ailoot 方法費率

Ailoot 圖片POST /v1/images/generations
輸入
US$0.00025 / 1K 圖片 Token
輸出
US$0.0336 每張 1K 圖片

Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →

參考費率詳情

模型層級的參考費率表不會變更方法選擇、報價或費用。實際計費採用所選 Ailoot 方法的費率。

模型參考費率表

各設定的價格

設定費率表費用
設定Ultra費率表基本費率費用
輸入 · 輸入 Token $0.00050000 / 1K Token
輸出 · 輸出 Token $0.0030000 / 1K Token
輸出 · 圖片輸出 $0.06000 / 1K Token
輸出 · 網頁搜尋 $0.028 每次網頁搜尋

請求範例

Ailoot · 圖片

curlPython SDKNode.js SDK
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
export AILOOT_API_KEY
export AILOOT_API_KEY
: "${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}"
export AILOOT_PROMPT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "gemini-3.1-flash-lite-image", "prompt": ""}')
f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Choose your actual UTF-8 brief")
p['prompt']=f.read_text(encoding="utf-8")
if not p['prompt'].strip():raise SystemExit("Brief must contain text")
Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

def save_images(items):
    if not items: raise SystemExit("No completed images; retain the full response")
    for index, item in enumerate(items):
        encoded=item.get("b64_json")
        uri=item.get("url", "")
        if not encoded and uri.startswith("data:image/"):
            header, separator, encoded=uri.partition(",")
            if not separator or ";base64" not in header: raise SystemExit("Unsupported image data URI")
        if encoded:
            raw=base64.b64decode(encoded,validate=True)
        elif uri:
            uri=urljoin("https://api.ailoot.ai",uri)
            parsed=urlsplit(uri)
            if parsed.scheme!="https" or not parsed.netloc or parsed.username or parsed.password:
                raise SystemExit("Invalid returned image URL")
            owned=parsed.netloc=="api.ailoot.ai" and parsed.path.startswith("/v1/media/assets/") and parsed.path.endswith("/content")
            args=["curl","--fail-with-body","--silent","--show-error",uri]
            if owned: args += ["-H","Authorization: Bearer "+os.environ["AILOOT_API_KEY"]]
            temporary=Path(f"image-{index}.bin")
            subprocess.run(args+["-o",str(temporary)],check=True)
            raw=temporary.read_bytes()
            temporary.unlink()
        else: raise SystemExit("Image has neither bytes nor URL")
        if not raw: raise SystemExit("Empty image result")
        ext="png" if raw.startswith(b"\x89PNG") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else "svg" if raw.lstrip().startswith((b"<svg",b"<?xml")) else "bin"
        Path(f"image-{index}.{ext}").write_bytes(raw)
    print("Every returned image saved; complete response metadata retained")
save_images(json.loads(Path("result.json").read_text())["data"])
PY_RESULT
from openai import OpenAI
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

def save_images(items):
    if not items: raise SystemExit("No completed images; retain the full response")
    for index, item in enumerate(items):
        encoded=item.get("b64_json")
        uri=item.get("url", "")
        if not encoded and uri.startswith("data:image/"):
            header, separator, encoded=uri.partition(",")
            if not separator or ";base64" not in header: raise SystemExit("Unsupported image data URI")
        if encoded:
            raw=base64.b64decode(encoded,validate=True)
        elif uri:
            uri=urljoin("https://api.ailoot.ai",uri)
            parsed=urlsplit(uri)
            if parsed.scheme!="https" or not parsed.netloc or parsed.username or parsed.password:
                raise SystemExit("Invalid returned image URL")
            owned=parsed.netloc=="api.ailoot.ai" and parsed.path.startswith("/v1/media/assets/") and parsed.path.endswith("/content")
            args=["curl","--fail-with-body","--silent","--show-error",uri]
            if owned: args += ["-H","Authorization: Bearer "+os.environ["AILOOT_API_KEY"]]
            temporary=Path(f"image-{index}.bin")
            subprocess.run(args+["-o",str(temporary)],check=True)
            raw=temporary.read_bytes()
            temporary.unlink()
        else: raise SystemExit("Image has neither bytes nor URL")
        if not raw: raise SystemExit("Empty image result")
        ext="png" if raw.startswith(b"\x89PNG") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else "svg" if raw.lstrip().startswith((b"<svg",b"<?xml")) else "bin"
        Path(f"image-{index}.{ext}").write_bytes(raw)
    print("Every returned image saved; complete response metadata retained")

f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Set your actual UTF-8 image brief file")
request={'model': 'gemini-3.1-flash-lite-image', 'prompt': ''}
request["prompt"]=f.read_text(encoding="utf-8")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.images.generate(**request)
Path("sdk-result.txt").write_text(str(result),encoding="utf-8")
save_images([{"b64_json":getattr(item,"b64_json",None),"url":getattr(item,"url",None)} for item in result.data])
import OpenAI from "openai";
import { readFileSync, writeFileSync } from "node:fs";
const key=process.env.AILOOT_API_KEY;
if(!key) throw new Error("Set your actual Ailoot API key");
const client=new OpenAI({baseURL:"https://api.ailoot.ai/v1",apiKey:key,maxRetries:0});
const request={"model": "gemini-3.1-flash-lite-image", "prompt": ""};
if(!process.env.AILOOT_PROMPT_FILE)throw new Error("Set your actual UTF-8 image brief file");
request.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,"utf8");
const result=await client.images.generate(request);
writeFileSync("sdk-result.json",JSON.stringify(result,null,2));
if(!result.data?.length) throw new Error("No completed images");
for(let index=0;index<result.data.length;index++) {
  const item=result.data[index];let encoded=item.b64_json,uri=item.url||"",raw;
  if(!encoded && uri.startsWith("data:image/")) {
    const comma=uri.indexOf(",");if(comma<0 || !uri.slice(0,comma).includes(";base64")) throw new Error("Unsupported image data URI");
    encoded=uri.slice(comma+1);
  }
  if(encoded) {
    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error("Invalid Base64");
    raw=Buffer.from(encoded,"base64");
  } else if(uri) {
    const u=new URL(uri,"https://api.ailoot.ai");
    if(u.protocol!=="https:" || u.username || u.password) throw new Error("Invalid returned URL");
    const owned=u.origin==="https://api.ailoot.ai" && u.pathname.startsWith("/v1/media/assets/") && u.pathname.endsWith("/content");
    const response=await fetch(u,{headers:owned?{Authorization:"Bearer "+key}:{},redirect:"manual"});
    if(!response.ok) throw new Error("Image content download failed: "+response.status);
    raw=Buffer.from(await response.arrayBuffer());
  } else throw new Error("Image has neither bytes nor URL");
  if(!raw.length) throw new Error("Empty image result");
  const ext=raw.subarray(0,4).equals(Buffer.from([137,80,78,71]))?"png":raw[0]===255&&raw[1]===216?"jpg":raw.toString("ascii",0,4)==="RIFF"&&raw.toString("ascii",8,12)==="WEBP"?"webp":raw.toString("utf8").trimStart().startsWith("<svg")||raw.toString("utf8").trimStart().startsWith("<?xml")?"svg":"bin";
  writeFileSync(`image-${index}.${ext}`,raw);
}
console.log("Every returned image saved; sdk-result.json retains complete metadata");

接收並儲存結果

Ailoot · 圖片

下載每張傳回的圖片,或儲存其 Base64 內容

  • GET /v1/media/tasks/{task_id}
  • GET /v1/media/assets/{asset_id}/content
  • GET /v1/media/assets
  • GET /v1/media/assets/{asset_id}
保留所有已完成的結果

請儲存每張已完成的圖片;從每個傳回的 URL 取得圖片,或解碼其 Base64 內容。

儲存所有資料項目。解碼每個 b64_json,或透過每個回傳的已簽署 URL 取得內容。依實際 MIME 類型/位元組內容選擇副檔名。

需要檢查原始回應時

若圖片生成或編輯結果需要檢查,請保留原始 operation_id/X-Client-Request-ID 與回傳的結果資訊。使用實際的 task_id 或 asset_id 值,透過媒體庫取回自己擁有的既有結果。請勿重新提交生成/編輯請求,也請勿以 operation_id 組成輪詢 URL。

回應欄位
欄位類型
欄位created類型integer
欄位data[].url類型string
欄位data[].b64_json類型base64 string
欄位usage類型object
錯誤與後續步驟
回應條件下一步
回應400 · invalid_request_error條件必要欄位、素材表示方式或參數值無效下一步提出新的建立請求前,先修正指定欄位。
回應server_error條件回傳的回應表示該作業或結果需要檢查下一步保留原始回傳的作業/任務 ID、請求標頭與回應;繼續以支援的方式讀取該原始作業。請勿重新提交建立請求。

別名

模型別名

Ailoot gemini-3.1-flash-lite-image
Ailoot Ultra google/gemini-3.1-flash-lite-image

方法路徑別名

/v1/images

相關呼叫用 ID

google/gemini-3.1-flash-lite-image, gemini-3.1-flash-lite-image

Ailoot Ultra · OpenAI Chat POST /v1/chat/completions google/gemini-3.1-flash-lite-image

google/gemini-3.1-flash-lite-image

Google /google/gemini-3.1-flash-lite-image

入門

Nano Banana 2 Lite 亦名 Gemini 3.1 Flash Lite Image,是 Google 用於快速視覺探索的圖像模型。公開設定接收文字與圖像,回傳圖像或文字,支援結合視覺參考素材的圖像需求。

接受的輸入
文字
結果
文字

Ailoot 可用 · 輸入與方法

Ailoot Ultra · OpenAI Chat POST /v1/chat/completions
輸入
text
輸出
text
輸出格式
json 或 SSE
欄位類型要求值與限制預設值
欄位model類型string要求必填值與限制
google/gemini-3.1-flash-lite-image
預設值—
欄位messages類型message[]要求必填值與限制
項目數下限: 1
預設值—
欄位messages[].role類型string要求必填值與限制
範例:system, user, assistant, tool, function
條件: 這些角色由 原始碼中的相容型別明確表示;確切角色集合仍依模型而定。
依模型而定
預設值—
欄位messages[].content類型string|content_part[]|null要求選填值與限制預設值—
欄位messages[].tool_calls類型tool_call[]要求選填值與限制預設值—
欄位messages[].tool_call_id類型string要求選填值與限制
適用條件: role=tool;使用實際回傳的 ID
預設值—
欄位messages[].name類型string要求選填值與限制預設值—
欄位messages[].reasoning_content類型string要求選填值與限制
適用條件: 此模型使用推理內容時,將實際回傳的推理內容帶回後續請求
預設值—
欄位messages[].reasoning_details類型object|array要求選填值與限制
依模型而定
預設值—
欄位max_tokens類型integer要求選填值與限制
最小值: 1
依模型而定
預設值—
欄位max_completion_tokens類型integer要求選填值與限制
最小值: 1
依模型而定
預設值—
欄位stream類型boolean要求選填值與限制預設值false
欄位stream_options.include_usage類型boolean要求選填值與限制
依模型而定
預設值—
欄位temperature類型number要求選填值與限制
依模型而定
預設值—
欄位top_p類型number要求選填值與限制
依模型而定
預設值—
欄位stop類型string|string[]要求選填值與限制
依模型而定
預設值—
欄位tools類型function_tool[]要求選填值與限制
依模型而定
預設值—
欄位tools[].type類型string要求選填值與限制
function
依模型而定
預設值—
欄位tools[].function.name類型string要求必填值與限制
適用條件: 已提供函式工具
預設值—
欄位tools[].function.description類型string要求選填值與限制預設值—
欄位tools[].function.parameters類型JSON_schema要求選填值與限制預設值—
欄位tool_choice類型string|object要求選填值與限制
依模型而定
預設值—
欄位parallel_tool_calls類型boolean要求選填值與限制
依模型而定
預設值—
欄位response_format類型object要求選填值與限制
依模型而定
預設值—
欄位reasoning_effort類型string要求選填值與限制
依模型而定
預設值—
欄位reasoning類型object要求選填值與限制
依模型而定
預設值—
欄位service_tier類型string要求選填值與限制
依模型而定
預設值—
欄位instructions類型string要求選填值與限制
相容性欄位
預設值—
欄位functions類型function[]要求選填值與限制
依模型而定
預設值—
欄位function_call類型string|object要求選填值與限制
依模型而定
預設值—
欄位prompt_cache_options類型object要求選填值與限制
依模型而定
預設值—
欄位modalities類型string[]要求選填值與限制
text
預設值—
欄位provider類型object要求選填值與限制
條件: 此 Ultra 文字路由拒絕 provider.options
預設值—
欄位cache_control.ttl類型string要求選填值與限制
條件: 實際提示詞快取位置拒絕 1h
預設值—
輸入素材組合

文字 · UTF8 文字

messages[].content

方法參數與生命週期
參數規格
參數content_type規格application/json
參數required規格model, messages
參數material_types規格text
參數messages規格具有 role/content 結構的訊息陣列
參數file_material規格實際 UTF-8 文件以原文文字插入;不推定檔案 ID
參數optional_controls規格stream, temperature, top_p, stop, max_tokens, max_completion_tokens, reasoning, response_format, tools, tool_choice
參數control_scope規格依模型而定;使用者函式工具與託管工具不同
參數output_modalities規格text
參數hosted_operations規格false
參數multimodal_input_binding規格null

生命週期: synchronous_or_streamed

將確切模型 ID 與 messages 一併送出。

上下文長度不是輸出上限。

文字檔案可提供原文文字;圖片/音訊/檔案物件輸入需要精確綁定。

方案

費率資訊不會增加請求選項。支援的參數列於所選方法中。

快速模式
標準費率 選取快速模式時
flex 模式
標準費率 選取 flex 模式時
最高推理強度
標準費率 最高推理強度採用 default 調整值時
推理強度 · high
標準費率 推理強度設為 high 時
推理強度 · minimal
標準費率 推理強度設為 minimal 時
顯式快取計價
未啟用 請求顯式快取時

Ailoot 費率

各設定的價格

請逐一核對各項費用與所列條件。每組互為替代選項的設定只套用一種費率。

設定費率表上下文 Token 數大於上下文 Token 數小於或等於費用
設定詞元基本費率費率表基本費率上下文 Token 數大於—上下文 Token 數小於或等於無上限費用
輸入 · 輸入 Token $0.0005 / 1K Token
輸出 · 輸出 Token $0.003 / 1K Token
輸入 · 讀取快取 — / 1K Token
輸入 · 寫入快取 — / 1K Token
輸入 · 寫入快取,1 小時 — / 1K Token
輸出 · 圖片輸出詞元 $0.06 / 1K 圖片 Token
設定請求長度級距 1費率表—上下文 Token 數大於0上下文 Token 數小於或等於無上限費用
輸入 · 輸入 Token $0.0005 / 1K Token
輸出 · 輸出 Token $0.003 / 1K Token
輸入 · 讀取快取 — / 1K Token
輸入 · 寫入快取 — / 1K Token
輸入 · 寫入快取,1 小時 — / 1K Token

參考費率詳情

模型層級的參考費率表不會變更方法選擇、報價或費用。實際計費採用所選 Ailoot 方法的費率。

Google: Nano Banana 2 Lite (Gemini 3.1 Flash Lite Image)

各設定的價格

設定計費條件費用
設定Google: Nano Banana 2 Lite (Gemini 3.1 Flash Lite Image) · 預設設定計費條件預設設定費用
輸入 · 輸入 Token US$0.0005 / 1K Token
輸出 · 輸出 Token US$0.003 / 1K Token
輸出 · 輸出圖片 US$0.06 / 1K Token
輸出 · 網頁搜尋 US$0.028 每次搜尋

Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →

請求範例

Ailoot Ultra · OpenAI Chat

curlPython SDKPython 串流
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "google/gemini-3.1-flash-lite-image", "messages": [{"role": "user", "content": "Explain the difference between an observation and a hypothesis in three sentences."}]}')

Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/chat/completions \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import json
from pathlib import Path
r=json.loads(Path("result.json").read_text())
for x in r.get("choices",[]):
    if x.get("message",{}).get("content"): print(x["message"]["content"])
PY_RESULT
from openai import OpenAI
import os

if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.chat.completions.create(model='google/gemini-3.1-flash-lite-image',messages=[{"role":"user","content":"Explain observations and hypotheses in three sentences."}])
import base64, json
from pathlib import Path

def save_result(data, stem="result"):
    # Keep every field, including usage, IDs, reasoning and tool requests.
    Path(stem + ".json").write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps(data, ensure_ascii=False, indent=2))
    def save_blob(encoded, suffix, label):
        raw = base64.b64decode(encoded, altchars=b"-_", validate=True)
        ext = "png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4] == b"RIFF" and raw[8:12] == b"WEBP" else suffix
        file = Path(stem + "-" + label + "." + ext)
        file.write_bytes(raw)
        print("Saved", file)
    for index, block in enumerate(data.get("content") or []):
        print("Content", index, json.dumps(block, ensure_ascii=False))
    for choice in data.get("choices") or []:
        print("Choice", choice.get("index"), json.dumps(choice.get("message", choice.get("delta", {})), ensure_ascii=False))
    for index, item in enumerate(data.get("output") or []):
        print("Output", index, json.dumps(item, ensure_ascii=False))
        if item.get("type") == "image_generation_call" and item.get("result"):
            save_blob(item["result"], item.get("output_format") or "bin", "output-" + str(index))
    for ci, candidate in enumerate(data.get("candidates") or []):
        for pi, part in enumerate((candidate.get("content") or {}).get("parts") or []):
            print("Candidate/part", ci, pi, json.dumps(part, ensure_ascii=False))
            blob = part.get("inlineData") or part.get("inline_data")
            if blob and blob.get("data"):
                mime = blob.get("mimeType") or blob.get("mime_type")
                suffix = {"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"}.get(mime, "bin")
                save_blob(blob["data"], suffix, "candidate-" + str(ci) + "-part-" + str(pi))

save_result(result.to_dict(mode="json"))
from openai import OpenAI
import os
from pathlib import Path

if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
import base64, json
from pathlib import Path

def save_result(data, stem="result"):
    # Keep every field, including usage, IDs, reasoning and tool requests.
    Path(stem + ".json").write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
    print(json.dumps(data, ensure_ascii=False, indent=2))
    def save_blob(encoded, suffix, label):
        raw = base64.b64decode(encoded, altchars=b"-_", validate=True)
        ext = "png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4] == b"RIFF" and raw[8:12] == b"WEBP" else suffix
        file = Path(stem + "-" + label + "." + ext)
        file.write_bytes(raw)
        print("Saved", file)
    for index, block in enumerate(data.get("content") or []):
        print("Content", index, json.dumps(block, ensure_ascii=False))
    for choice in data.get("choices") or []:
        print("Choice", choice.get("index"), json.dumps(choice.get("message", choice.get("delta", {})), ensure_ascii=False))
    for index, item in enumerate(data.get("output") or []):
        print("Output", index, json.dumps(item, ensure_ascii=False))
        if item.get("type") == "image_generation_call" and item.get("result"):
            save_blob(item["result"], item.get("output_format") or "bin", "output-" + str(index))
    for ci, candidate in enumerate(data.get("candidates") or []):
        for pi, part in enumerate((candidate.get("content") or {}).get("parts") or []):
            print("Candidate/part", ci, pi, json.dumps(part, ensure_ascii=False))
            blob = part.get("inlineData") or part.get("inline_data")
            if blob and blob.get("data"):
                mime = blob.get("mimeType") or blob.get("mime_type")
                suffix = {"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"}.get(mime, "bin")
                save_blob(blob["data"], suffix, "candidate-" + str(ci) + "-part-" + str(pi))

with client.chat.completions.stream(model='google/gemini-3.1-flash-lite-image',messages=[{"role":"user","content":"Explain observations and hypotheses in three sentences."}]) as stream:
    with Path("stream-events.jsonl").open("w",encoding="utf-8") as log:
        for event in stream:
            payload=event.to_dict(mode="json")
            log.write(json.dumps(payload,ensure_ascii=False)+"\n"); log.flush()
            print(json.dumps(payload,ensure_ascii=False))
    final=stream.get_final_completion()
    save_result(final.to_dict(mode="json"),"stream-result")

接收並儲存結果

Ailoot Ultra · OpenAI Chat

json 或 SSE

保留所有已完成的結果

請保留所有完整傳回的回應、檔案與內容區塊。

保留每個候選項及其內容/工具呼叫/推理。SSE 中依候選項/工具索引組合增量,保留最終完成原因與用量。

需要檢查原始回應時

保留請求/回應 ID 與標頭。未提供通用的文字工作擷取 URL。

回應欄位
欄位類型
欄位choices[].index類型integer
欄位choices[].message.content類型string|null
欄位choices[].message.tool_calls類型tool_call[]
欄位choices[].message.reasoning_content類型string
欄位choices[].message.reasoning_details類型object|array
欄位choices[].finish_reason類型string|null
欄位usage類型object
錯誤與後續步驟
回應條件下一步
回應400 · invalid_request_error條件必要欄位、素材表示方式或參數值無效下一步提出新的建立請求前,先修正指定欄位。

別名

模型別名

Ailoot gemini-3.1-flash-lite-image
Ailoot Ultra google/gemini-3.1-flash-lite-image

方法路徑別名

/v1/images

相關呼叫用 ID

google/gemini-3.1-flash-lite-image, gemini-3.1-flash-lite-image

Ailoot Ultra · 圖片 POST /v1/images/generations google/gemini-3.1-flash-lite-image

google/gemini-3.1-flash-lite-image

Google /google/gemini-3.1-flash-lite-image

入門

Nano Banana 2 Lite 亦名 Gemini 3.1 Flash Lite Image,是 Google 用於快速視覺探索的圖像模型。公開設定接收文字與圖像,回傳圖像或文字,支援結合視覺參考素材的圖像需求。

接受的輸入
文字 · 圖片
結果
圖片

Ailoot 可用 · 輸入與方法

Ailoot Ultra · 圖片 POST /v1/images/generations
輸入
text, image
輸出
image
欄位類型要求值與限制預設值
欄位model類型string要求必填值與限制
google/gemini-3.1-flash-lite-image
預設值—
欄位prompt類型string要求必填值與限制
長度下限: 1
預設值—
欄位resolution類型string要求選填值與限制
1K
預設值—
欄位aspect_ratio類型string要求選填值與限制
1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9
預設值—
欄位n類型integer要求選填值與限制
最小值: 1
最大值: 1
預設值—
欄位input_references類型array要求選填值與限制
項目數下限: 0
項目數上限: 14
預設值—
欄位provider類型object要求選填值與限制預設值—
方法參數與生命週期
參數規格
參數content_type規格application/json
參數required規格model, prompt
參數material_types規格text, image

生命週期: synchronous_result_then_owned_library

GET /v1/media/tasks/{task_id} · 實際回傳的 task_id 或媒體庫紀錄

GET /v1/media/assets/{asset_id}/content

GET /v1/media/assets

GET /v1/media/assets/{asset_id}

方案

最終費用的計算方式

顯示的費率用於在生成前估算費用。最終費用依原始生成作業記錄的成本計算。實測的輸出時間長度與預估數量並非最終計費數量。

費率資訊不會增加請求選項。支援的參數列於所選方法中。

快速模式
未指定 選取快速模式時
flex 模式
未指定 選取 flex 模式時
最高推理強度
未指定 最高推理強度採用 default 調整值時

供比較的預估費率

各設定的價格

請逐一核對各項費用與所列條件。每組互為替代選項的設定只套用一種費率。

設定費率表預估數量費用
設定基礎 token 費率費率表基本費率預估數量—費用
輸入 · 輸入 Token · 僅供比較的估算 — / 1K Token
輸出 · 輸出 Token · 僅供比較的估算 — / 1K Token
輸入 · 讀取快取 · 僅供比較的估算 — / 1K Token
輸入 · 寫入快取 · 僅供比較的估算 — / 1K Token
輸入 · 寫入快取,1 小時 · 僅供比較的估算 — / 1K Token
設定預估生成費用費率表—預估數量單次生成估算值費用
輸出 · 預估生成費用 · 僅供比較的估算 $0.24576 生成前估算

此估算並非額外費用,也不是本次生成完成後的固定費率。

Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →

請求範例

Ailoot Ultra · 圖片

curl
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
export AILOOT_API_KEY
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p={'model': 'google/gemini-3.1-flash-lite-image', 'prompt': 'a red panda astronaut floating in space, studio lighting'}

Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

def save_images(items):
    if not items: raise SystemExit("No completed images; retain the full response")
    for index, item in enumerate(items):
        encoded=item.get("b64_json")
        uri=item.get("url", "")
        if not encoded and uri.startswith("data:image/"):
            header, separator, encoded=uri.partition(",")
            if not separator or ";base64" not in header: raise SystemExit("Unsupported image data URI")
        if encoded:
            raw=base64.b64decode(encoded,validate=True)
        elif uri:
            uri=urljoin("https://api.ailoot.ai",uri)
            parsed=urlsplit(uri)
            if parsed.scheme!="https" or not parsed.netloc or parsed.username or parsed.password:
                raise SystemExit("Invalid returned image URL")
            owned=parsed.netloc=="api.ailoot.ai" and parsed.path.startswith("/v1/media/assets/") and parsed.path.endswith("/content")
            args=["curl","--fail-with-body","--silent","--show-error",uri]
            if owned: args += ["-H","Authorization: Bearer "+os.environ["AILOOT_API_KEY"]]
            temporary=Path(f"image-{index}.bin")
            subprocess.run(args+["-o",str(temporary)],check=True)
            raw=temporary.read_bytes()
            temporary.unlink()
        else: raise SystemExit("Image has neither bytes nor URL")
        if not raw: raise SystemExit("Empty image result")
        ext="png" if raw.startswith(b"\x89PNG") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else "svg" if raw.lstrip().startswith((b"<svg",b"<?xml")) else "bin"
        Path(f"image-{index}.{ext}").write_bytes(raw)
    print("Every returned image saved; complete response metadata retained")
save_images(json.loads(Path("result.json").read_text())["data"])
PY_RESULT

接收並儲存結果

Ailoot Ultra · 圖片

下載每張傳回的圖片,或儲存其 Base64 內容

  • GET /v1/media/tasks/{task_id}
  • GET /v1/media/assets/{asset_id}/content
  • GET /v1/media/assets
  • GET /v1/media/assets/{asset_id}
其他內容讀取方式
讀取現有且屬於自己的素材
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/media/assets \
  -H "Authorization: Bearer $AILOOT_API_KEY" -o owned-assets.json
# Preserve every returned asset and follow its exact signed content URL. Do not construct a signed token.
保留所有已完成的結果

請儲存每張已完成的圖片;從每個傳回的 URL 取得圖片,或解碼其 Base64 內容。

保留完整回應與標頭、所有實際輸出、原始回傳的識別碼,以及所有用量欄位。恢復原始作業時,請勿再次提交建立請求。

需要檢查原始回應時

保留回傳的 X-Client-Request-ID,以供核對。僅讀取實際回傳的 task_id/asset_id 值或自己擁有的媒體庫;請勿以作業 ID 組成任務 URL,也請勿重新提交建立請求。

回應欄位
欄位類型
欄位created類型
欄位data[].url類型
欄位data[].b64_json類型
欄位usage類型

別名

模型別名

Ailoot gemini-3.1-flash-lite-image
Ailoot Ultra google/gemini-3.1-flash-lite-image

方法路徑別名

/v1/images

相關呼叫用 ID

google/gemini-3.1-flash-lite-image, gemini-3.1-flash-lite-image

Ailoot Ultra · Anthropic Messages POST /v1/messages google/gemini-3.1-flash-lite-image

google/gemini-3.1-flash-lite-image

Google /google/gemini-3.1-flash-lite-image

入門

Nano Banana 2 Lite 亦名 Gemini 3.1 Flash Lite Image,是 Google 用於快速視覺探索的圖像模型。公開設定接收文字與圖像,回傳圖像或文字,支援結合視覺參考素材的圖像需求。

接受的輸入
文字
結果
json · sse

Ailoot 可用 · 輸入與方法

Ailoot Ultra · Anthropic Messages POST /v1/messages
輸入
text
輸出
json, sse
輸出格式
JSON 或 SSE
欄位類型要求值與限制預設值
欄位model類型string要求必填值與限制
google/gemini-3.1-flash-lite-image
預設值—
欄位messages類型message[]要求必填值與限制預設值—
欄位messages[].role類型string要求必填值與限制
user, assistant
預設值—
欄位messages[].content類型string要求必填值與限制預設值—
欄位max_tokens類型integer要求必填值與限制預設值—
欄位stream類型boolean要求選填值與限制預設值false
輸入素材組合

文字 · UTF-8 文字

messages[].content 字串

方法參數與生命週期
參數規格
參數content_type規格application/json
參數required規格model, messages, max_tokens
參數optional_controls規格stream
參數material_types規格text
參數text_file_material規格讀取實際 UTF-8 文件,將文字放入指定的 input 或訊息內容字串。

生命週期: synchronous_or_streamed

方案

費率資訊不會增加請求選項。支援的參數列於所選方法中。

快速模式
標準費率 選取快速模式時
flex 模式
標準費率 選取 flex 模式時
最高推理強度
標準費率 最高推理強度採用 default 調整值時
推理強度 · high
標準費率 推理強度設為 high 時
推理強度 · minimal
標準費率 推理強度設為 minimal 時
顯式快取計價
未啟用 請求顯式快取時

Ailoot 費率

各設定的價格

請逐一核對各項費用與所列條件。每組互為替代選項的設定只套用一種費率。

設定費率表上下文 Token 數大於上下文 Token 數小於或等於費用
設定詞元基本費率費率表基本費率上下文 Token 數大於—上下文 Token 數小於或等於無上限費用
輸入 · 輸入 Token $0.0005 / 1K Token
輸出 · 輸出 Token $0.003 / 1K Token
輸入 · 讀取快取 — / 1K Token
輸入 · 寫入快取 — / 1K Token
輸入 · 寫入快取,1 小時 — / 1K Token
輸出 · 圖片輸出詞元 $0.06 / 1K 圖片 Token
設定請求長度級距 1費率表—上下文 Token 數大於0上下文 Token 數小於或等於無上限費用
輸入 · 輸入 Token $0.0005 / 1K Token
輸出 · 輸出 Token $0.003 / 1K Token
輸入 · 讀取快取 — / 1K Token
輸入 · 寫入快取 — / 1K Token
輸入 · 寫入快取,1 小時 — / 1K Token

Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →

請求範例

Ailoot Ultra · Anthropic Messages

完整的最小 JSON 請求主體curl · 使用您的 UTF-8 文件Python · 儲存完整結果
{
  "model": "google/gemini-3.1-flash-lite-image",
  "max_tokens": 128,
  "messages": [
    {
      "role": "user",
      "content": "Summarize the incident report."
    }
  ],
  "stream": false
}
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
: "${AILOOT_TEXT_FILE:?Set your actual UTF-8 document}"
export AILOOT_TEXT_FILE
python3 - <<'PY_REQUEST'
import json, os
from pathlib import Path

source_file = Path(os.environ['AILOOT_TEXT_FILE'])
if not source_file.is_file():
    raise SystemExit('Set AILOOT_TEXT_FILE to your actual UTF-8 document')
text = source_file.read_text(encoding='utf-8')
if not text.strip():
    raise SystemExit('Choose a document containing text')
payload = {'model': 'google/gemini-3.1-flash-lite-image', 'max_tokens': 128, 'messages': [{'role': 'user', 'content': 'Summarize the incident report.'}]}
payload['messages'][0]['content'] = 'Summarize this material and quote supporting source passages.\n\n' + text
Path('request.json').write_text(json.dumps(payload, ensure_ascii=False), encoding='utf-8')
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/messages \
  -H "x-api-key: $AILOOT_API_KEY" -H 'anthropic-version: 2023-06-01' -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import json
from pathlib import Path

result = json.loads(Path('result.json').read_text(encoding='utf-8'))
print(json.dumps(result, ensure_ascii=False, indent=2))
PY_RESULT
import json, os
from pathlib import Path

source_file = Path(os.environ['AILOOT_TEXT_FILE'])
if not source_file.is_file():
    raise SystemExit('Set AILOOT_TEXT_FILE to your actual UTF-8 document')
text = source_file.read_text(encoding='utf-8')
if not text.strip():
    raise SystemExit('Choose a document containing text')
payload = {'model': 'google/gemini-3.1-flash-lite-image', 'max_tokens': 128, 'messages': [{'role': 'user', 'content': 'Summarize the incident report.'}]}
payload['messages'][0]['content'] = 'Summarize this material and quote supporting source passages.\n\n' + text
from urllib.request import Request, urlopen
from urllib.error import HTTPError

api_key = os.environ['AILOOT_API_KEY']
if not api_key.strip():
    raise SystemExit('Set AILOOT_API_KEY before making a request')
headers = {'x-api-key': 'PLACEHOLDER_KEY', 'anthropic-version': '2023-06-01', 'Content-Type': 'application/json'}
headers['x-api-key'] = api_key
request = Request('https://api.ailoot.ai/v1/messages', data=json.dumps(payload, ensure_ascii=False).encode('utf-8'), headers=headers, method='POST')
try:
    with urlopen(request, timeout=120) as response:
        raw = response.read()
        Path('response-headers.txt').write_text(str(response.headers), encoding='utf-8')
except HTTPError as error:
    Path('result.json').write_bytes(error.read())
    Path('response-headers.txt').write_text(str(error.headers), encoding='utf-8')
    raise
Path('result.json').write_bytes(raw)
import json
from pathlib import Path

result = json.loads(Path('result.json').read_text(encoding='utf-8'))
print(json.dumps(result, ensure_ascii=False, indent=2))

接收並儲存結果

Ailoot Ultra · Anthropic Messages

JSON 或 SSE

保留所有已完成的結果

請保留所有完整傳回的回應、檔案與內容區塊。

保留所有內容區塊、思考簽章與實際工具使用 ID。組合所有 SSE 區塊增量;第一個文字區塊不是完整輸出。

需要檢查原始回應時

保留請求/回應 ID 與標頭。未提供通用的文字工作擷取 URL。

回應欄位
欄位類型
欄位id類型string
欄位model類型string
欄位content[]類型text|thinking|tool_use|other content block
欄位stop_reason類型string|null
欄位usage類型object
錯誤與後續步驟
回應條件下一步
回應400 · invalid_request_error條件必要欄位、素材表示方式或參數值無效下一步提出新的建立請求前,先修正指定欄位。

別名

模型別名

Ailoot gemini-3.1-flash-lite-image
Ailoot Ultra google/gemini-3.1-flash-lite-image

方法路徑別名

/v1/images

相關呼叫用 ID

google/gemini-3.1-flash-lite-image, gemini-3.1-flash-lite-image

FAQ · Google: Nano Banana 2 Lite (Gemini 3.1 Flash Lite Image)
可以使用哪些輸入與結果?

POST /v1/images/generations · gemini-3.1-flash-lite-image: text → image

POST /v1/chat/completions · google/gemini-3.1-flash-lite-image: text → text

POST /v1/images/generations · google/gemini-3.1-flash-lite-image: text, image → image

POST /v1/messages · google/gemini-3.1-flash-lite-image: text → json, sse

請求使用哪些欄位?

POST /v1/images/generations · gemini-3.1-flash-lite-image: model, prompt, n, response_format, stream

POST /v1/chat/completions · google/gemini-3.1-flash-lite-image: model, messages, stream, modalities, provider

POST /v1/images/generations · google/gemini-3.1-flash-lite-image: model, prompt, resolution, aspect_ratio, n, input_references, provider

POST /v1/messages · google/gemini-3.1-flash-lite-image: model, messages, max_tokens, stream

適用哪些限制?

POST /v1/images/generations · gemini-3.1-flash-lite-image: ctx: 65536; max_out: 4096; n.minimum: 1

POST /v1/chat/completions · google/gemini-3.1-flash-lite-image: messages.min_items: 1

POST /v1/images/generations · google/gemini-3.1-flash-lite-image: n.minimum: 1; n.maximum: 1

更多詳情

將 Ailoot 串接 Claude Code、OpenCode、Hermes 或自己的應用程式。

公司及其專案組合

公司及其專案組合:數百萬客戶,每月銷售額達數十億。

優惠購買 token。

訂閱優惠適合持續工作,折扣碼購買 token 最高可折 50%。

訂閱
為定期請求選擇優惠方案。
最高 50% 折扣碼
購買時輸入代碼,價格依活動重算。
歷史中的費用
每次請求保存模型、token 與金額。

選擇訂閱 · 查看模型價格

將 API 加入 你銷售的產品。

依 Ailoot 正式服務條款與授權合約串接 SaaS、應用程式與機器人;轉售請申請經銷授權。

商用應用程式
在付費功能加入文字、圖片、影片與聲音生成。
經銷授權
提供專案說明與存取方式,要求書面使用和轉售條件。
網站文件
串接前可閱讀正式服務條款、授權合約與資料處理政策。

申請經銷授權 · 正式服務條款與授權合約