Gemini 3.1 Pro Low
文字及圖片對話,上下文 1,048,576 tokens,輸出上限 65,536 tokens。
- Ailoot · Anthropic Messages
POST /v1/messagesgemini-3.1-pro-low - Ailoot · Gemini generateContent
POST /v1beta/models/{model}:generateContentgemini-3.1-pro-low
關於模型
此說明介紹模型的能力。Ailoot 可用的輸入、輸出與選項,依所選方法列於下方。
gemini-3.1-pro-low 接受文字及圖片、輸出文字,context 列為 1,048,576 tokens,輸出上限 65,536。可比較圖表及說明文字,結構化指出數字支持或牴觸敘述處。
可選 Messages 或 Gemini generateContent,圖片依該介面格式;Messages 必填 max_tokens,Gemini 用 contents、parts。Low 識別設定,沒有與此名稱綁定的 effort enum 或數值推理預算。上下文及輸出是不同上限,大視窗不允許百萬 token 答案。
實用任務
實用任務
英文技術範例
Review a proposal against criteria
Review this office proposal against the stated criteria. Criteria: capacity at least 12 people, step-free access and monthly rent no more than 2,000 units. Proposal: 14 desks, rent 1,900 units, entrance reached by six stairs; lift information is absent. Return a criterion table and the single clarification that matters before acceptance.預期結果
A criterion-by-criterion assessment with evidence and a question about step-free access.檢查結果
Check that absent lift information is recorded as unresolved rather than assumed accessible.Ailoot · Anthropic Messages POST /v1/messages gemini-3.1-pro-low
gemini-3.1-pro-low入門
文字及圖片對話,上下文 1,048,576 tokens,輸出上限 65,536 tokens。
- 接受的輸入
- 文字 · 圖片
- 結果
- 文字
Ailoot 可用 · 輸入與方法
Ailoot · Anthropic Messages POST /v1/messages
- 輸入
text,image- 輸出
text- 上下文
- 1,048,576 tokens
- 輸出上限
- 65,536 tokens
- 輸出格式
- json 或 SSE
| 欄位 | 類型 | 要求 | 值與限制 | 預設值 |
|---|---|---|---|---|
欄位model | 類型string | 要求必填 | 值與限制 gemini-3.1-pro-low | 預設值— |
欄位messages | 類型message[] | 要求必填 | 值與限制 項目數下限: 1 | 預設值— |
欄位messages[].role | 類型string | 要求必填 | 值與限制 user, assistant | 預設值— |
欄位messages[].content | 類型string|content_block[] | 要求必填 | 值與限制 | 預設值— |
欄位system | 類型string|content_block[] | 要求選填 | 值與限制 | 預設值— |
欄位max_tokens | 類型integer | 要求必填 | 值與限制 最小值: 1 限制適用對象: 所選模型/卡片的確切上限 | 預設值— |
欄位stream | 類型boolean | 要求選填 | 值與限制 | 預設值false |
欄位temperature | 類型number | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位top_p | 類型number | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位stop_sequences | 類型string[] | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位tools | 類型tool[] | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位tools[].name | 類型string | 要求選填 | 值與限制 適用條件: 已提供工具 | 預設值— |
欄位tools[].description | 類型string | 要求選填 | 值與限制 | 預設值— |
欄位tools[].input_schema | 類型JSON_schema | 要求選填 | 值與限制 | 預設值— |
欄位tool_choice | 類型object | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位thinking.type | 類型string | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位thinking.budget_tokens | 類型integer | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位output_config.effort | 類型string | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位metadata | 類型object | 要求選填 | 值與限制 | 預設值— |
欄位cache_control | 類型object | 要求選填 | 值與限制 依模型而定 | 預設值— |
輸入素材組合
文字 · UTF8 文字
messages[].content 或 type=text 區塊
文字 + 圖片
{type:image,source:{type:base64,media_type,data}} 或 type=url 的來源
方法參數與生命週期
| 參數 | 規格 |
|---|---|
參數material_types | 規格text, image |
參數required | 規格model, messages, max_tokens |
參數optional_controls | 規格null |
參數content_type | 規格application/json |
參數text_file_material | 規格實際 UTF-8 內容以文字插入;檔案 ID/URLs 需要另有精確支援 |
生命週期: exact retained published method
方法結構與 ID 均為精確值;供應商能力與准入狀態分開。
方案
Ailoot 方法費率
POST /v1/messages- 輸入
- US$0.002 / 1K
- 輸出
- US$0.012 / 1K
- 讀取快取
- US$0.0002 / 1K
依請求長度計價 · Anthropic Messages
| 請求大小,tokens | 輸入 | 輸出 | 讀取快取 | 寫入快取 | 快取 5 分鐘 | 快取 1 小時 |
|---|---|---|---|---|---|---|
| 請求大小,tokens(0; 200,000] | 輸入US$0.002 | 輸出US$0.012 | 讀取快取US$0.0002 | 寫入快取基本費率:— | 快取 5 分鐘基本費率:— | 快取 1 小時基本費率:— |
| 請求大小,tokens(200,000; ∞) | 輸入US$0.004 | 輸出US$0.018 | 讀取快取US$0.0004 | 寫入快取基本費率:— | 快取 5 分鐘基本費率:— | 快取 1 小時基本費率:— |
費率單位為每 1K Token 的 USD 金額。 未設定費率時,會沿用此方法的基本費率;«—» 表示未設定基本費率。
Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →
請求範例
Ailoot · Anthropic Messages
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
: "${AILOOT_TEXT_FILE:?Set your actual UTF-8 source-material file}"
export AILOOT_TEXT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "gemini-3.1-pro-low", "max_tokens": 1024, "messages": []}')
f=Path(os.environ["AILOOT_TEXT_FILE"])
if not f.is_file():raise SystemExit("Choose your actual UTF-8 source material")
text=f.read_text(encoding="utf-8")
if not text.strip():raise SystemExit("Source material must contain text")
p["messages"]=[{"role":"user","content":"Summarize this material and quote supporting source passages.\n\n"+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/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
print(json.dumps(json.loads(Path("result.json").read_text()),ensure_ascii=False,indent=2))
PY_RESULT
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
: "${AILOOT_IMAGE_FILE:?Set your actual PNG JPEG or WebP image}"
export AILOOT_IMAGE_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "gemini-3.1-pro-low", "max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": "text", "text": "Read labels and numbers in this image; flag unreadable text."}]}]}')
import base64
f=Path(os.environ["AILOOT_IMAGE_FILE"])
if not f.is_file():raise SystemExit("Choose an actual PNG JPEG or WebP image")
raw=f.read_bytes()
mime="image/png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "image/jpeg" if raw.startswith(b"\xff\xd8") else "image/webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else None
if not mime:raise SystemExit("Use PNG JPEG or WebP")
b64=base64.b64encode(raw).decode()
p["messages"][0]["content"].append({"type":"image","source":{"type":"base64","media_type":mime,"data":b64}})
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/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
print(json.dumps(json.loads(Path("result.json").read_text()),ensure_ascii=False,indent=2))
PY_RESULT
import anthropic
import os
if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client = anthropic.Anthropic(base_url="https://api.ailoot.ai", api_key=os.environ["AILOOT_API_KEY"], max_retries=0)
msg = client.messages.create(
model="gemini-3.1-pro-low",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain the difference between an observation and a hypothesis 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(msg.to_dict(mode="json"))
import Anthropic from "@anthropic-ai/sdk";
if (!process.env.AILOOT_API_KEY?.trim()) throw new Error("Set AILOOT_API_KEY before making a request");
const client = new Anthropic({ baseURL: "https://api.ailoot.ai", apiKey: process.env.AILOOT_API_KEY, maxRetries: 0 });
const msg = await client.messages.create({
model: "gemini-3.1-pro-low",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain the difference between an observation and a hypothesis in three sentences." }],
});
import { writeFileSync } from "node:fs";
function saveResult(data, stem = "result") {
writeFileSync(stem + ".json", JSON.stringify(data, null, 2));
console.log(JSON.stringify(data, null, 2));
const saveBlob = (encoded, suffix, label) => {
const raw = Buffer.from(encoded, "base64");
const ext = raw.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10])) ? "png" : raw[0]===255 && raw[1]===216 ? "jpg" : raw.subarray(0,4).toString()==="RIFF" && raw.subarray(8,12).toString()==="WEBP" ? "webp" : suffix;
const file = `${stem}-${label}.${ext}`;
writeFileSync(file, raw); console.log("Saved", file);
};
for (const [i, block] of (data.content || []).entries()) console.log("Content", i, JSON.stringify(block));
for (const choice of data.choices || []) console.log("Choice", choice.index, JSON.stringify(choice.message || choice.delta || {}));
for (const [i, item] of (data.output || []).entries()) {
console.log("Output", i, JSON.stringify(item));
if (item.type === "image_generation_call" && item.result) saveBlob(item.result, item.output_format || "bin", `output-${i}`);
}
for (const [ci, candidate] of (data.candidates || []).entries()) {
for (const [pi, part] of (candidate.content?.parts || []).entries()) {
console.log("Candidate/part", ci, pi, JSON.stringify(part));
const blob = part.inlineData || part.inline_data;
if (blob?.data) {
const mime = blob.mimeType || blob.mime_type;
const suffix = ({"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"})[mime] || "bin";
saveBlob(blob.data, suffix, `candidate-${ci}-part-${pi}`);
}
}
}
}
saveResult(msg);
import anthropic,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=anthropic.Anthropic(base_url="https://api.ailoot.ai",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.messages.stream(model='gemini-3.1-pro-low',max_tokens=1024,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_message()
save_result(final.to_dict(mode="json"),"stream-result")
接收並儲存結果
Ailoot · 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-pro-low
方法路徑別名
請使用上方列出的 API 方法路徑。
相關呼叫用 ID
Ailoot · Gemini generateContent POST /v1beta/models/{model}:generateContent gemini-3.1-pro-low
gemini-3.1-pro-low入門
文字及圖片對話,上下文 1,048,576 tokens,輸出上限 65,536 tokens。
- 接受的輸入
- 文字 · 圖片
- 結果
- 文字
Ailoot 可用 · 輸入與方法
Ailoot · Gemini generateContent POST /v1beta/models/{model}:generateContent
- 輸入
text,image- 輸出
text- 上下文
- 1,048,576 tokens
- 輸出上限
- 65,536 tokens
- 輸出格式
- json 或支援的串流
| 欄位 | 類型 | 要求 | 值與限制 | 預設值 |
|---|---|---|---|---|
欄位path.model | 類型string | 要求必填 | 值與限制 gemini-3.1-pro-low | 預設值— |
欄位contents | 類型content[] | 要求必填 | 值與限制 項目數下限: 1 | 預設值— |
欄位contents[].role | 類型string | 要求選填 | 值與限制 user, model | 預設值— |
欄位contents[].parts | 類型part[] | 要求必填 | 值與限制 | 預設值— |
欄位systemInstruction | 類型content | 要求選填 | 值與限制 | 預設值— |
欄位generationConfig.maxOutputTokens | 類型integer | 要求選填 | 值與限制 最小值: 1 依模型而定 | 預設值— |
欄位generationConfig.temperature | 類型number | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位generationConfig.topP | 類型number | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位generationConfig.topK | 類型integer | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位generationConfig.stopSequences | 類型string[] | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位generationConfig.thinkingConfig.includeThoughts | 類型boolean | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位generationConfig.thinkingConfig.thinkingBudget | 類型integer | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位tools[].functionDeclarations | 類型function_declaration[] | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位toolConfig.functionCallingConfig.mode | 類型string | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位safetySettings | 類型object[] | 要求選填 | 值與限制 依模型而定 | 預設值— |
欄位sessionId | 類型string | 要求選填 | 值與限制 | 預設值— |
輸入素材組合
文字 · UTF8 文字
contents[].parts[].text
文字 + 圖片
parts[].inlineData={mimeType,data}
方法參數與生命週期
| 參數 | 規格 |
|---|---|
參數material_types | 規格text, image |
參數required | 規格contents |
參數optional_controls | 規格null |
參數content_type | 規格application/json |
參數text_file_material | 規格實際 UTF-8 內容以文字插入;檔案 ID/URLs 需要另有精確支援 |
生命週期: exact retained published method
方法結構與 ID 均為精確值;供應商能力與准入狀態分開。
方案
Ailoot 方法費率
POST /v1beta/models/{model}:generateContent- 輸入
- US$0.002 / 1K
- 輸出
- US$0.012 / 1K
- 讀取快取
- US$0.0002 / 1K
依請求長度計價 · Gemini generateContent
| 請求大小,tokens | 輸入 | 輸出 | 讀取快取 | 寫入快取 | 快取 5 分鐘 | 快取 1 小時 |
|---|---|---|---|---|---|---|
| 請求大小,tokens(0; 200,000] | 輸入US$0.002 | 輸出US$0.012 | 讀取快取US$0.0002 | 寫入快取基本費率:— | 快取 5 分鐘基本費率:— | 快取 1 小時基本費率:— |
| 請求大小,tokens(200,000; ∞) | 輸入US$0.004 | 輸出US$0.018 | 讀取快取US$0.0004 | 寫入快取基本費率:— | 快取 5 分鐘基本費率:— | 快取 1 小時基本費率:— |
費率單位為每 1K Token 的 USD 金額。 未設定費率時,會沿用此方法的基本費率;«—» 表示未設定基本費率。
Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →
請求範例
Ailoot · Gemini generateContent
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
: "${AILOOT_TEXT_FILE:?Set your actual UTF-8 source-material file}"
export AILOOT_TEXT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"contents": []}')
f=Path(os.environ["AILOOT_TEXT_FILE"])
if not f.is_file():raise SystemExit("Choose your actual UTF-8 source material")
text=f.read_text(encoding="utf-8")
if not text.strip():raise SystemExit("Source material must contain text")
p["contents"]=[{"role":"user","parts":[{"text":"Summarize this material and quote supporting source passages.\n\n"+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/v1beta/models/gemini-3.1-pro-low:generateContent \
-H "x-goog-api-key: $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
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(json.loads(Path("result.json").read_text(encoding="utf-8")))
PY_RESULT
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
: "${AILOOT_IMAGE_FILE:?Set your actual PNG JPEG or WebP image}"
export AILOOT_IMAGE_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"contents": [{"role": "user", "parts": [{"text": "Read labels and numbers in this image; flag unreadable text."}]}]}')
import base64
f=Path(os.environ["AILOOT_IMAGE_FILE"])
if not f.is_file():raise SystemExit("Choose an actual PNG JPEG or WebP image")
raw=f.read_bytes()
mime="image/png" if raw.startswith(b"\x89PNG\r\n\x1a\n") else "image/jpeg" if raw.startswith(b"\xff\xd8") else "image/webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else None
if not mime:raise SystemExit("Use PNG JPEG or WebP")
b64=base64.b64encode(raw).decode()
p["contents"][0]["parts"].append({"inlineData":{"mimeType":mime,"data":b64}})
Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1beta/models/gemini-3.1-pro-low:generateContent \
-H "x-goog-api-key: $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
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(json.loads(Path("result.json").read_text(encoding="utf-8")))
PY_RESULT
from google import genai
from google.genai import types
import os
if not os.environ.get("AILOOT_API_KEY", "").strip(): raise SystemExit("Set AILOOT_API_KEY before making a request")
client = genai.Client(
api_key=os.environ["AILOOT_API_KEY"],
http_options=types.HttpOptions(base_url="https://api.ailoot.ai"),
)
resp = client.models.generate_content(model="gemini-3.1-pro-low", contents="Explain the difference between an observation and a hypothesis 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(resp.to_json_dict())
import { GoogleGenAI } from "@google/genai";
if (!process.env.AILOOT_API_KEY?.trim()) throw new Error("Set AILOOT_API_KEY before making a request");
const ai = new GoogleGenAI({ apiKey: process.env.AILOOT_API_KEY, httpOptions: { baseUrl: "https://api.ailoot.ai" } });
const resp = await ai.models.generateContent({ model: "gemini-3.1-pro-low", contents: "Explain the difference between an observation and a hypothesis in three sentences." });
import { writeFileSync } from "node:fs";
function saveResult(data, stem = "result") {
writeFileSync(stem + ".json", JSON.stringify(data, null, 2));
console.log(JSON.stringify(data, null, 2));
const saveBlob = (encoded, suffix, label) => {
const raw = Buffer.from(encoded, "base64");
const ext = raw.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10])) ? "png" : raw[0]===255 && raw[1]===216 ? "jpg" : raw.subarray(0,4).toString()==="RIFF" && raw.subarray(8,12).toString()==="WEBP" ? "webp" : suffix;
const file = `${stem}-${label}.${ext}`;
writeFileSync(file, raw); console.log("Saved", file);
};
for (const [i, block] of (data.content || []).entries()) console.log("Content", i, JSON.stringify(block));
for (const choice of data.choices || []) console.log("Choice", choice.index, JSON.stringify(choice.message || choice.delta || {}));
for (const [i, item] of (data.output || []).entries()) {
console.log("Output", i, JSON.stringify(item));
if (item.type === "image_generation_call" && item.result) saveBlob(item.result, item.output_format || "bin", `output-${i}`);
}
for (const [ci, candidate] of (data.candidates || []).entries()) {
for (const [pi, part] of (candidate.content?.parts || []).entries()) {
console.log("Candidate/part", ci, pi, JSON.stringify(part));
const blob = part.inlineData || part.inline_data;
if (blob?.data) {
const mime = blob.mimeType || blob.mime_type;
const suffix = ({"image/png":"png", "image/jpeg":"jpg", "image/webp":"webp", "audio/wav":"wav", "audio/mpeg":"mp3", "video/mp4":"mp4"})[mime] || "bin";
saveBlob(blob.data, suffix, `candidate-${ci}-part-${pi}`);
}
}
}
}
saveResult(resp);
from google import genai
from google.genai import types
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=genai.Client(api_key=os.environ["AILOOT_API_KEY"],http_options=types.HttpOptions(base_url="https://api.ailoot.ai"))
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))
count=0
with Path("stream-events.jsonl").open("w",encoding="utf-8") as log:
for chunk in client.models.generate_content_stream(model='gemini-3.1-pro-low',contents="Explain observations and hypotheses in three sentences."):
payload=chunk.to_json_dict()
log.write(json.dumps(payload,ensure_ascii=False)+"\n"); log.flush()
save_result(payload,"stream-chunk-"+str(count))
count+=1
接收並儲存結果
Ailoot · Gemini generateContent
json 或支援的串流
保留所有已完成的結果
請保留所有完整傳回的回應、檔案與內容區塊。
保留所有候選項與部分,包括函式呼叫、思考簽章與用量;依序組合串流片段。
需要檢查原始回應時
保留請求/回應 ID 與標頭。未提供通用的文字工作擷取 URL。
回應欄位
| 欄位 | 類型 |
|---|---|
欄位responseId | 類型string |
欄位modelVersion | 類型string |
欄位candidates[].content.parts[] | 類型text|inlineData|functionCall|other part |
欄位candidates[].finishReason | 類型string |
欄位usageMetadata | 類型object |
錯誤與後續步驟
| 回應 | 條件 | 下一步 |
|---|---|---|
回應400 · invalid_request_error | 條件必要欄位、素材表示方式或參數值無效 | 下一步提出新的建立請求前,先修正指定欄位。 |
別名
模型別名
Ailoot gemini-3.1-pro-low
方法路徑別名
請使用上方列出的 API 方法路徑。
相關呼叫用 ID
FAQ · Gemini 3.1 Pro Low
- 可以使用哪些輸入與結果?
POST /v1/messages·gemini-3.1-pro-low:text,image→textPOST /v1beta/models/{model}:generateContent·gemini-3.1-pro-low:text,image→text- 請求使用哪些欄位?
POST /v1/messages·gemini-3.1-pro-low:model,messages,system,max_tokens,stream,metadataPOST /v1beta/models/{model}:generateContent·gemini-3.1-pro-low:contents,systemInstruction,sessionId- 適用哪些限制?
POST /v1/messages·gemini-3.1-pro-low:ctx:1048576;max_out:65536;messages.min_items:1;max_tokens.minimum:1POST /v1beta/models/{model}:generateContent·gemini-3.1-pro-low:ctx:1048576;max_out:65536;contents.min_items:1