File size: 943 Bytes
e4731a8
cb67f1d
 
 
 
 
15d980c
 
 
 
cb67f1d
 
15d980c
 
cb67f1d
15d980c
cb67f1d
15d980c
cb67f1d
15d980c
cb67f1d
 
 
 
15d980c
cb67f1d
 
 
 
 
 
 
 
 
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
# backend/scripts/check_groq_models.py
"""
Utility script to check available Groq LLM models.
Requires GROQ_API_KEY in backend/.env.
"""

import os
import requests
from dotenv import load_dotenv
from pathlib import Path

# Load environment variables
load_dotenv(dotenv_path=Path(__file__).resolve().parent / ".env")

API_URL = "https://api.groq.com/openai/v1/models"
api_key = os.getenv("GROQ_API_KEY")

if not api_key:
    raise SystemExit("❌ Error: GROQ_API_KEY not set in backend/.env")

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

try:
    resp = requests.get(API_URL, headers=headers, timeout=15)
    resp.raise_for_status()
    data = resp.json().get("data", [])
    print("\nAvailable Groq models:\n")
    for m in data:
        print("-", m.get("id") or m.get("model") or m.get("name") or m)
except requests.exceptions.RequestException as e:
    print(f"API request failed: {e}")