Source: https://ailoot.ai/models/zh-hant-tw/gemini-3-7-flash-high/
Canonical: https://ailoot.ai/models/zh-hant-tw/gemini-3-7-flash-high/
Language: zh-hant-tw

# Gemini 3.7 Flash High

[Markdown](https://ailoot.ai/models/zh-hant-tw/gemini-3-7-flash-high/index.md) · [JSON](https://ailoot.ai/models/zh-hant-tw/gemini-3-7-flash-high/facts.json)

## [Gemini 3.7 Flash High](https://ailoot.ai/models/zh-hant-tw/gemini-3-7-flash-high/)

Google 的多模態模型，可調整推理力度，用於程式開發、影片理解與多步驟工作流程。

- [**Ailoot · Anthropic Messages** `POST /v1/messages` `gemini-3.7-flash-high`](https://ailoot.ai/models/zh-hant-tw/gemini-3-7-flash-high/#method-0)
- [**Ailoot · Gemini generateContent** `POST /v1beta/models/{model}:generateContent` `gemini-3.7-flash-high`](https://ailoot.ai/models/zh-hant-tw/gemini-3-7-flash-high/#method-1)

關於模型

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

Gemini 3.7 Flash 延續具備推理能力的多模態模型系列。它基於 Gemini 3.6 Flash，更新了推理基礎，並支援代理流程中的影片理解。工作情境包括程式開發、複雜影片分析與多階段流程。

#### 輸入與文字結果

依 Google 公布的特性，模型理解**文字、影像、影片、音訊與 PDF**。Ailoot API 目前目錄中的文字方法，公布的輸入為**文字與影像**，輸出為文字；影片、音訊與 PDF 不在這組輸入之中。請求最多為 **1 048 576 個輸入 token**，回覆最多為 **65 536 個輸出 token**。回覆仍為文字；這個版本不支援自行生成影像或音訊。

#### 推理控制

Thinking 支援三種等級：**`low`、`medium` 與 `high`**。Google 所描述的基礎模型模式，預設等級為 `medium`。這些值描述 Google 的基礎模型；透過 Ailoot API 可使用哪個模式、能否調整，取決於所選方法與模型版本。這些等級可用來選擇額外推理的強度。Gemini 3.7 Flash **不支援** `minimal`，使用這個參數會造成錯誤。推理設定影響模型的工作模式，不會改變支援的輸出類型。

為循序完成任務，模型提供函式呼叫、程式碼執行及結構化回覆。它可使用上下文快取、檔案搜尋、以搜尋結果作為依據、Google Maps 與網址內容，也支援批次處理。電腦介面控制標示為預覽功能，使用時需要所選方法提供支援。

#### 能力的邊界

穩定版本 `gemini-3.7-flash` 於 2026 年八月推出。廠商公布的內建知識截止時間為 2026 年三月，並註明某些領域可能仍停留在 2025 年一月。處理外部資料或理解傳入內容，與模型原本具備的知識是不同的事情。

模型可能產生虛構事實，個別請求可能執行緩慢或逾時。它適合複雜的工作循環，但能完成個別動作，不會取代對整個流程最終結果的驗證。使用多模態輸入時，結果是針對資料內容的文字結論，而不是新的媒體檔案。

實用任務

### 實用任務

英文技術範例

```
Handle malformed input without losing rows

Revise this Python parser: rows = [line.split(",") for line in text.splitlines()]; totals = [int(row[1]) for row in rows]. Input: A,3
B,unknown
C,5. Return valid records plus line-numbered errors; reject extra or missing columns. Include tests for malformed quantity and wrong column count. Keep processing after a bad line.
```

#### 預期結果

```
A proposed parser function, its result shape and tests showing valid rows retained alongside line-numbered errors.
```

#### 檢查結果

```
Check that the middle malformed row cannot discard A or C and that column-count errors remain distinct from quantity errors.
```

**Ailoot · Anthropic Messages** `POST /v1/messages` `gemini-3.7-flash-high`

[`gemini-3.7-flash-high`](https://ailoot.ai/models/zh-hant-tw/#m=gemini-3.7-flash-high&route=Core&caller=gemini-3.7-flash-high&fmt=messages)

Google /`gemini-3.7-flash-high`

### 入門

Google 的多模態模型，可調整推理力度，用於程式開發、影片理解與多步驟工作流程。

接受的輸入

文字 · 圖片

結果

文字

### Ailoot 可用 · 輸入與方法

**Ailoot · Anthropic Messages** `POST /v1/messages`

輸入

`text`, `image`

輸出

`text`

上下文

1,048,576 tokens

輸出上限

65,536 tokens

輸出格式

json 或 SSE

| 欄位 | 類型 | 要求 | 值與限制 | 預設值 |
| --- | --- | --- | --- | --- |
| 欄位`model` | 類型`string` | 要求必填 | 值與限制 gemini-3.7-flash-high | 預設值— |
| 欄位`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 方法費率

輸入

US$0.00075 */ 1K*

輸出

US$0.00375 */ 1K*

讀取快取

US$0.000075 */ 1K*

Ailoot 會在請求前預留估算金額。取得結果後，依實測用量結算最終費用。串流結算採用最終用量紀錄。[預留金額與結算的運作方式 →](https://ailoot.ai/docs/zh-hant-tw/billing/reserve/)

### 請求範例

#### Ailoot · Anthropic Messages

文字範例輸入，圖片Python SDKNode.js SDKPython 串流

```bash
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.7-flash-high", "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
```

```bash
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.7-flash-high", "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
```

```python
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.7-flash-high",
    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"))
```

```js
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.7-flash-high",
  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);
```

```python
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.7-flash-high',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.7-flash-high`](https://ailoot.ai/models/zh-hant-tw/#m=gemini-3.7-flash-high&route=Core&caller=gemini-3.7-flash-high&fmt=messages)

#### 方法路徑別名

請使用上方列出的 API 方法路徑。

#### 相關呼叫用 ID

[`gemini-3.7-flash-high`](https://ailoot.ai/models/zh-hant-tw/#m=gemini-3.7-flash-high&route=Core&caller=gemini-3.7-flash-high&fmt=messages)

**Ailoot · Gemini generateContent** `POST /v1beta/models/{model}:generateContent` `gemini-3.7-flash-high`

[`gemini-3.7-flash-high`](https://ailoot.ai/models/zh-hant-tw/#m=gemini-3.7-flash-high&route=Core&caller=gemini-3.7-flash-high&fmt=gemini)

Google /`gemini-3.7-flash-high`

### 入門

Google 的多模態模型，可調整推理力度，用於程式開發、影片理解與多步驟工作流程。

接受的輸入

文字 · 圖片

結果

文字

### Ailoot 可用 · 輸入與方法

**Ailoot · Gemini generateContent** `POST /v1beta/models/{model}:generateContent`

輸入

`text`, `image`

輸出

`text`

輸出格式

json 或支援的串流

| 欄位 | 類型 | 要求 | 值與限制 | 預設值 |
| --- | --- | --- | --- | --- |
| 欄位`path.model` | 類型`string` | 要求必填 | 值與限制 gemini-3.7-flash-high | 預設值— |
| 欄位`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 方法費率

輸入

US$0.00075 */ 1K*

輸出

US$0.00375 */ 1K*

讀取快取

US$0.000075 */ 1K*

Ailoot 會在請求前預留估算金額。取得結果後，依實測用量結算最終費用。串流結算採用最終用量紀錄。[預留金額與結算的運作方式 →](https://ailoot.ai/docs/zh-hant-tw/billing/reserve/)

### 請求範例

#### Ailoot · Gemini generateContent

文字範例輸入，圖片Python SDKNode.js SDKPython 串流

```bash
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.7-flash-high: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
```

```bash
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.7-flash-high: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
```

```python
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.7-flash-high", 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())
```

```js
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.7-flash-high", 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);
```

```python
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.7-flash-high',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.7-flash-high`](https://ailoot.ai/models/zh-hant-tw/#m=gemini-3.7-flash-high&route=Core&caller=gemini-3.7-flash-high&fmt=gemini)

#### 方法路徑別名

請使用上方列出的 API 方法路徑。

#### 相關呼叫用 ID

[`gemini-3.7-flash-high`](https://ailoot.ai/models/zh-hant-tw/#m=gemini-3.7-flash-high&route=Core&caller=gemini-3.7-flash-high&fmt=gemini)

FAQ · Gemini 3.7 Flash High

可以使用哪些輸入與結果？

`POST /v1/messages` · `gemini-3.7-flash-high`: `text`, `image` → `text` `POST /v1beta/models/{model}:generateContent` · `gemini-3.7-flash-high`: `text`, `image` → `text`

請求使用哪些欄位？

`POST /v1/messages` · `gemini-3.7-flash-high`: `model`, `messages`, `system`, `max_tokens`, `stream`, `metadata` `POST /v1beta/models/{model}:generateContent` · `gemini-3.7-flash-high`: `contents`, `systemInstruction`, `sessionId`

適用哪些限制？

`POST /v1/messages` · `gemini-3.7-flash-high`: `ctx`: `1048576`; `max_out`: `65536`; `messages.min_items`: `1`; `max_tokens.minimum`: `1` `POST /v1beta/models/{model}:generateContent` · `gemini-3.7-flash-high`: `contents.min_items`: `1`

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

## 公司及其專案組合

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

## 優惠購買 token。

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

訂閱

為定期請求選擇優惠方案。

最高 50% 折扣碼

購買時輸入代碼，價格依活動重算。

歷史中的費用

每次請求保存模型、token 與金額。

[選擇訂閱](https://ailoot.ai/docs/zh-hant-tw/billing/subscriptions/) · [查看模型價格](https://ailoot.ai/models/zh-hant-tw/)

## 將 API 加入 你銷售的產品。

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

商用應用程式

在付費功能加入文字、圖片、影片與聲音生成。

經銷授權

提供專案說明與存取方式，要求書面使用和轉售條件。

網站文件

串接前可閱讀正式服務條款、授權合約與資料處理政策。

[申請經銷授權](mailto:support@ailoot.ai) · [正式服務條款與授權合約](https://ailoot.ai/legal/offer?lang=zh-hant-tw)

## Ailoot · 公司及其專案組合





Ailoot以累積的營運經驗、廣大的客戶群、穩定的服務及持續的KPI管理為基礎。





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





Ailoot將這些營運經驗用於API存取，讓客戶的產品、代理、應用程式及自動化流程使用AI功能。
