ValueError
ValueError: Invalid model name format for Groq meta-llama inference
Stack trace
ValueError: Invalid model name 'llama-3.3-70b'. Groq expects format 'meta-llama/Llama-3.3-70B-Instruct' or valid Groq model ID. Check https://console.groq.com/docs/models for current available models.
Why it happens
Together AI and Groq each use different model naming conventions. Groq's API expects fully qualified model names like 'meta-llama/Llama-3.3-70B-Instruct' (case-sensitive) or Groq-specific IDs like 'mixtral-8x7b-32768', while developers often use shorthand names like 'llama-3.3-70b'. Additionally, model availability changes frequently: some models may be deprecated or region-locked, and the exact casing matters for Groq's model router.
Detection
Catch ValueError during client initialization or model selection. Log the model_name parameter you're passing and compare it against Groq's official model list at https://console.groq.com/docs/models. Add a validation function that checks model names before API calls.
Causes & fixes
Using shorthand model name (e.g., 'llama-3.3-70b') instead of fully qualified Groq model ID
Replace with the exact Groq model ID: 'meta-llama/Llama-3.3-70B-Instruct' (case-sensitive). Check Groq's current model list at https://console.groq.com/docs/models and copy the exact ID.
Incorrect casing in model name (e.g., 'meta-llama/llama-3.3-70b-instruct' instead of 'meta-llama/Llama-3.3-70B-Instruct')
Match the exact casing from Groq's model list. Groq model IDs are case-sensitive. Use 'meta-llama/Llama-3.3-70B-Instruct' with capital L, B, and I.
Model is not available on Groq (deprecated, region-restricted, or no longer offered)
Verify the model is in Groq's current available models list. Call client.models.list() to see what's actually available in your region, or switch to a guaranteed-available model like 'mixtral-8x7b-32768'.
Environment variable GROQ_API_MODEL or similar is set to an invalid name
Check environment variables with 'echo $GROQ_API_MODEL' and update to a valid Groq model ID. Use hardcoded valid model names in code until you confirm the env var is correct.
Code: broken vs fixed
import os
from groq import Groq
client = Groq(api_key=os.environ.get('GROQ_API_KEY'))
# BROKEN: using shorthand model name
response = client.chat.completions.create(
model='llama-3.3-70b', # ❌ WRONG: Groq doesn't accept shorthand names
messages=[{'role': 'user', 'content': 'Hello'}]
)
print(response.choices[0].message.content) import os
from groq import Groq
client = Groq(api_key=os.environ.get('GROQ_API_KEY'))
# FIXED: using exact Groq model ID with correct casing
response = client.chat.completions.create(
model='meta-llama/Llama-3.3-70B-Instruct', # ✅ FIXED: fully qualified Groq model ID, case-sensitive
messages=[{'role': 'user', 'content': 'Hello'}]
)
print('Response:', response.choices[0].message.content) Workaround
If you don't know the exact model ID, call client.models.list() to fetch all available models and use the ID from the response. Extract model.id from the response and use that directly, bypassing guessing the name format.
Prevention
Store a mapping of friendly model names to Groq model IDs in your config. Before each API call, validate the model name exists in Groq's current model list using a startup health check. Use environment variables only for API keys, not model names: hardcode validated model IDs in code or fetch them from Groq's API once at startup and cache them.