-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_models.py
More file actions
52 lines (42 loc) · 1.33 KB
/
Copy pathlist_models.py
File metadata and controls
52 lines (42 loc) · 1.33 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import requests
import os
from dotenv import load_dotenv
import json
load_dotenv()
api_key = os.getenv("KEYWORDS_AI_API_KEY")
url = "https://api.keywordsai.co/api/models"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
try:
print(f"GET {url}")
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
# Handle OpenAI-style response format
if 'data' in data:
models = data['data']
else:
models = data
print(f"\nFound {len(models)} models.")
gemini_models = []
for m in models:
# Check if m is dict (it should be)
if isinstance(m, dict):
mid = m.get('id', str(m))
else:
mid = str(m)
if 'gemini' in mid.lower():
gemini_models.append(mid)
print("\nGemini models available:")
for m in gemini_models:
print(f"- {m}")
if not gemini_models:
print("No Gemini models found. First 10 models:")
for m in models[:10]:
print(m)
else:
print(f"Error {response.status_code}: {response.text}")
except Exception as e:
print(f"Exception: {e}")