MCPcopy
hub / github.com/cheahjs/free-llm-api-resources / fetch_groq_models

Function fetch_groq_models

src/pull_available_models.py:124–157  ·  view source on GitHub ↗
(logger)

Source from the content-addressed store, hash-verified

122
123
124def fetch_groq_models(logger):
125 logger.info("Fetching Groq models...")
126 r = requests.get(
127 "https://api.groq.com/openai/v1/models",
128 headers={
129 "Authorization": f'Bearer {os.environ["GROQ_API_KEY"]}',
130 "Content-Type": "application/json",
131 },
132 )
133 r.raise_for_status()
134 models = r.json()["data"]
135 logger.debug(json.dumps(models, indent=4))
136 ret_models = []
137 with ThreadPoolExecutor() as executor:
138 futures = []
139 for model in models:
140 future = executor.submit(
141 get_groq_limits_for_model, model["id"], script_dir, logger
142 )
143 futures.append((model, future))
144
145 for model, future in futures:
146 limits = future.result()
147 if limits is None:
148 continue
149 ret_models.append(
150 {
151 "id": model["id"],
152 "name": get_model_name(model["id"]),
153 "limits": limits,
154 }
155 )
156 ret_models = sorted(ret_models, key=lambda x: x["name"])
157 return ret_models
158
159
160def fetch_kluster_models(logger):

Callers 1

mainFunction · 0.85

Calls 1

get_model_nameFunction · 0.85

Tested by

no test coverage detected