為每個請求選擇 Auto、TokenLab Verified 或 Official,並預先顯示價格。 查看最新動態

Gemini 3.5 Flash API for Agents:已棄用,請使用 Gemini 3.8 Flash

·2026年9月19日·約 7 分鐘閱讀·更新 2026年11月11日·2274 次瀏覽
#Gemini#AI 代理#模型棄用#AI API
Gemini 3.5 Flash API for Agents:已棄用,請使用 Gemini 3.8 Flash

Gemini 3.5 Flash 已被棄用。TokenLab 目錄於 2026-10-08 將 gemini-3.5-flash 標記為棄用,並指定 gemini-3.6-flash 作為其替代品。最新的 Flash 模型是 gemini-3.8-flash,在 TokenLab 上,其每個 token 的成本大約只有前者的一半。本頁面展示了 2026-11-11 各個 Gemini Flash ID 的狀態、各自的成本,以及當模型 ID 被棄用時,如何保持 Agent 迴圈正常運作。

重點摘要

  • 請勿在 gemini-3.5-flash 上開始新的工作。TokenLab 將其階段列為 deprecated,且 Google 已不再於 Google AI Studio 中提供該模型。
  • 請為新的 Agent 使用 gemini-3.8-flash。它具有相同的 1,048,576 個 token 輸入限制和 65,536 個 token 輸出限制。TokenLab 價格:每 1M tokens 輸入 $0.375 / 輸出 $1.875。
  • gemini-3.6-flash 是目錄中指定的替代品。Google 會將舊 ID 的請求路由至該模型。在 TokenLab 上的價格為 $0.75 / $3.75。
  • TokenLab 和 Google 皆未宣布 gemini-3.5-flash 的停用日期。棄用的 ID 隨時可能停止運作,因此請依照您自己的時程進行遷移。
  • 使用 GET /v1/models/{id} 檢查您使用的每個模型 ID 的生命週期。該端點是公開的,不需要 API key。

2026-11-11 Gemini Flash ID 的狀態

TokenLab 的欄位來自 GET /v1/models/{id}。Google 的欄位來自 Gemini API 棄用頁面。

模型 ID TokenLab 階段 棄用日期 目錄中的替代品 Google 狀態
gemini-3.5-flash deprecated 2026-10-08 gemini-3.6-flash Google AI Studio 中已不再提供。端點並未關閉,會將請求路由至 gemini-3.6-flash。
gemini-3.6-flash active 無 無 2026-07-21 發布。未宣布關閉日期。
gemini-3.7-flash deprecated 2026-10-08 gemini-3.8-flash Google AI Studio 中已不再提供。端點會將請求路由至 gemini-3.8-flash。
gemini-3.8-flash active, marked latest 無 無 2026-09-02 發布。Google 稱其為最聰明的 Flash 模型。未宣布關閉日期。
gemini-3.5-flash-lite active 無 無 未宣布關閉日期。

棄用的模型仍會列在目錄中。階段資訊會提醒您在 ID 停用前規劃遷移。已停用的模型會從模型列表中移除。

價格

價格為每 1M tokens 的美元金額,讀取時間為 2026-11-11。「TokenLab 價格」為驗證後的價格。「定價」為 Google 或其他製造商公布的價格。

模型 ID 角色 TokenLab 價格 (輸入 / 輸出) 定價 (輸入 / 輸出)
gemini-3.8-flash 用於新 Agent $0.375 / $1.875 2026-12-31 前為 $0.75 / $3.75,之後為 $1.50 / $7.50
gemini-3.6-flash 目錄中指定的替代品 $0.75 / $3.75 2026-12-31 前為 $0.75 / $3.75,之後為 $1.50 / $7.50
gemini-3.5-flash 已棄用 $0.75 / $4.50 $1.50 / $9 (已不在 Google 的價格頁面上)
gemini-3.5-flash-lite 更便宜的 Google 備援 $0.15 / $1.25 $0.30 / $2.50
gpt-6.1-terra 來自其他製造商的備援 $0.30 / $1.50 $1 / $5

Google 的 價格頁面 指出 Gemini 3.8 Flash 和 Gemini 3.6 Flash 的推廣價格將於 2026-12-31 結束。自 2027-01-01 起,Google 列出的價格為 $1.50 / $7.50。該日期之後,請使用 GET /v1/models/gemini-3.8-flash/pricing 再次查看 TokenLab 價格。

以下是一個基於既定假設的範例。一個 Agent 進行 10 次模型呼叫。每次呼叫發送 20,000 個輸入 token 並返回 1,000 個輸出 token,且無快取。總計為 200,000 個輸入和 10,000 個輸出 token。

  • gemini-3.5-flash:0.2 × $0.75 + 0.01 × $4.50 = $0.195。
  • gemini-3.6-flash:0.2 × $0.75 + 0.01 × $3.75 = $0.1875。
  • gemini-3.8-flash:0.2 × $0.375 + 0.01 × $1.875 = $0.09375,比 gemini-3.5-flash 便宜約 52%。

在 gemini-3.8-flash 上,輸出 token 的成本是輸入 token 的 5 倍。Google 將思考 token 計為輸出,因此冗長的推理過程會增加輸出計數。請在每次呼叫時使用 max_tokens 限制回應長度。

遷移至 Gemini 3.8 Flash 的變更事項

Google 的 Gemini 3.8 Flash 新功能 頁面列出了 Gemini API 的以下遷移步驟:

  • 將 thinking_budget 取代為 thinking_level。數值為 low、medium(預設值)和 high。數值 minimal 會返回錯誤。
  • 從請求中移除 temperature、top_p、top_k 和 candidate_count。
  • 移除預填寫的模型對話輪次 (prefilled model turns)。對於多輪對話,Google 建議使用伺服器端的 previous_interaction_id。
  • 保留先前輪次的思考簽名 (thought signatures)。
  • 使用 generateContent 時,在每個 FunctionResponse 中發送 call_id 和 name。

不同端點對參數的處理方式可能不同,因此在切換之前,請先透過您使用的端點發送幾個真實請求。請比較答案以及完成任務的成本,而不僅僅是每個 token 的價格。

當模型被棄用時該怎麼做

  1. 閱讀生命週期。 GET /v1/models/{id} 會返回 tokenlab.lifecycle,其中包含 stage、deprecated_at、retired_at 和 replacement_model。請在 CI 中並定期執行此檢查。
  2. 檢查替代品是否合適。 在替代品的記錄中比較輸入和輸出限制、接受的請求格式、功能和價格。替代品可能會改變品質、價格、上下文長度和工具支援。
  3. 在您自己的任務上進行測試。 使用相同的提示詞 (prompts) 和工具。比較正確性、重試次數以及完成每個任務的成本。
  4. 在一個地方進行切換。 將模型 ID 保存在一個設定檔中,並在每個請求中明確發送 ID。
  5. 保留經過測試的備援。 如果已停用的 ID 返回 400 model_not_found,您預先測試過的備援可以保持迴圈運作。

TokenLab 不會自行為請求選擇不同的模型。Agent 錯誤指南建議明確發送選擇的模型 ID,若模型遺失則會返回 model_not_found,有時會附帶 did_you_mean 欄位。在製造商停用模型後,TokenLab 可能會將舊 ID 路由至替代品並發布在 更新日誌 中。在 2026-10-22,deepseek-v4-flash 以這種方式開始作為 deepseek-v4.1-flash 執行,並按替代品的價格計費。請勿依賴此行為。當 ID 背後的模型變更時,價格和輸出可能會隨之改變。

當您依賴的模型遺失、非活躍,或現在解析為不同的 ID 時,此腳本會以代碼 1 退出:

import json
import sys
import urllib.error
import urllib.request

BASE = "https://api.tokenlab.sh/v1/models/"
MODELS = ["gemini-3.8-flash", "gemini-3.5-flash-lite", "gemini-3.5-flash"]


def read_record(model_id):
    try:
        with urllib.request.urlopen(BASE + model_id, timeout=15) as resp:
            return json.load(resp)
    except urllib.error.HTTPError as exc:
        if exc.code == 404:
            return None  # model_not_found: the ID does not exist
        raise


failed = False
for model_id in MODELS:
    record = read_record(model_id)
    if record is None:
        print(f"{model_id}: not found")
        failed = True
    elif record["id"] != model_id:
        print(f"{model_id}: now resolves to {record['id']}")
        failed = True
    elif record["tokenlab"]["lifecycle"]["stage"] != "active":
        life = record["tokenlab"]["lifecycle"]
        print(f"{model_id}: stage={life['stage']}, deprecated_at={life['deprecated_at']}, "
              f"retired_at={life['retired_at']}, replacement={life['replacement_model']}")
        failed = True
    else:
        print(f"{model_id}: active")
sys.exit(1 if failed else 0)

在 2026-11-11,它列印了 gemini-3.8-flash: active、gemini-3.5-flash-lite: active 以及 gemini-3.5-flash 的棄用行,其替代品為 gemini-3.6-flash。

帶有測試備援的 Agent 呼叫

以下函數向 gemini-3.8-flash 發送 Chat Completions 請求,並僅在找不到 ID 時才移動到下一個模型。其他錯誤(例如 429)會被拋出,以便您自己的重試代碼可以處理它們。錯誤處理指南列出了哪些狀態可以安全重試。

import os
from openai import OpenAI, APIStatusError

client = OpenAI(
    api_key=os.environ["TOKENLAB_API_KEY"],
    base_url="https://api.tokenlab.sh/v1",
    timeout=60.0,
    max_retries=0,
)

# Order matters. Every fallback is a model you have tested for this job.
MODELS = ["gemini-3.8-flash", "gpt-6.1-terra"]


def error_code(exc):
    body = exc.body if isinstance(exc.body, dict) else {}
    error = body.get("error", body)
    return error.get("code") if isinstance(error, dict) else None


def chat(messages, tools=None, max_tokens=1024):
    for model in MODELS:
        kwargs = {"model": model, "messages": messages, "max_tokens": max_tokens}
        if tools:
            kwargs["tools"] = tools
        try:
            return model, client.chat.completions.create(**kwargs)
        except APIStatusError as exc:
            if error_code(exc) != "model_not_found":
                raise  # other errors need their own handling
            print(f"{model} is not available, trying the next model")
    raise RuntimeError("no configured model is available")

請記錄每個請求是由哪個模型回答的。來自其他製造商的備援可能會改變價格、上下文限制和工具行為。當模型變更時,請告知您的使用者。

常見問題

我還可以使用 gemini-3.5-flash 嗎?

TokenLab 目錄仍將其列為 deprecated 階段,且沒有停用日期。Google 表示其該 ID 的端點不會關閉,並會將請求路由至 gemini-3.6-flash。請勿在其上開始新的工作。請遷移至 gemini-3.8-flash 並先測試您的提示詞。

什麼模型取代了 gemini-3.5-flash?

目錄中指定的是 gemini-3.6-flash。對於新的工作,請使用 gemini-3.8-flash。它更新、具有相同的上下文和輸出限制,且在 TokenLab 上成本更低。

TokenLab 會自動幫我切換到新模型嗎?

預設不會。請明確發送模型 ID。當製造商停用模型時,TokenLab 可能會將舊 ID 路由至替代品並在更新日誌中宣布,但您不應依賴此行為。

Gemini 3.8 Flash 比 Gemini 3.5 Flash 便宜多少?

在 TokenLab 上,輸入成本為每 1M tokens $0.375 對比 $0.75,輸出成本為 $1.875 對比 $4.50。在上述 10 次呼叫的範例中,成本從 $0.195 降至 $0.09375。Google 的 Gemini 3.8 Flash 定價將於 2027-01-01 加倍。

我如何知道我使用的模型是否已棄用?

從 GET /v1/models/{id} 讀取 tokenlab.lifecycle。若 stage 不是 active,或者有 deprecated_at 日期或 replacement_model 值,則表示您應該規劃遷移。取得模型參考說明了這些欄位。

建立 TokenLab API key 並在部署前檢查目前的模型 ID。

來源

價格觀測於 2026-11-11

本文由 TokenLab 的 AI Agent 撰寫,事實已在所示日期對照文中連結的一手來源核對。

相關模型

最近發布的模型

用本文涉及的模型開始構建

比較價格、測試路由,把文章研究直接變成可執行的 API 呼叫。

第一次呼叫 API

取得 API 金鑰
curl https://api.tokenlab.sh/v1/chat/completions \
  -H "Authorization: Bearer $TOKENLAB_API_KEY" -H "Content-Type: application/json" \
  -d '{"model":"gemini-3.8-flash","messages":[{"role":"user","content":"Hello!"}]}'