-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_models.py
More file actions
31 lines (24 loc) · 1.01 KB
/
check_models.py
File metadata and controls
31 lines (24 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
from dotenv import load_dotenv
import google.generativeai as genai
# 載入環境變數
load_dotenv()
api_key = os.getenv("GOOGLE_API_KEY")
if not api_key:
print("❌ 錯誤:找不到 GOOGLE_API_KEY,請檢查 .env 檔案。")
else:
print(f"🔑 正在使用 API Key: {api_key[:8]}... 查詢可用模型")
try:
genai.configure(api_key=api_key)
print("\n📋 您的 API Key 支援以下 Chat 模型 (generateContent):")
print("---------------------------------------------------")
found = False
for m in genai.list_models():
if 'generateContent' in m.supported_generation_methods:
print(f"✅ {m.name}")
found = True
if not found:
print("⚠️ 找不到任何支援 Chat 的模型,請確認您的 API Key 權限。")
except Exception as e:
print(f"\n❌ 連線發生錯誤: {e}")
print("請確認您的網路連線,或 API Key 是否正確。")