Groq API key setup
Published 2026-10-13 ยท Updated 2026-10-18
Groq keys start with gsk_ followed by a long alphanumeric body. The API is OpenAI-compatible, the free tier is genuinely useful, and the inference speed is the reason people put up with the limited model list.
Setup
export GROQ_API_KEY="gsk_..."
Base URL: https://api.groq.com/openai/v1, note the openai segment in the path.
Verify
curl https://api.groq.com/openai/v1/models \
-H "Authorization: Bearer $GROQ_API_KEY"
Python
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["GROQ_API_KEY"],
base_url="https://api.groq.com/openai/v1",
)
resp = client.chat.completions.create(
model="llama-4-scout",
messages=[{"role": "user", "content": "Say hello"}],
)
print(resp.choices[0].message.content)
Groq also has its own groq Python package, but unless you need provider-specific features the OpenAI SDK is simpler.
Notes
- Model list changes fast. Groq is an inference host, not a lab, it serves Llama, Qwen, Mixtral-class open weights. Model ids like
llama-4-scoutorqwen-3-480bcome and go with the upstream releases;/modelsis the source of truth. - The free tier is real but capped. Generous requests-per-day, modest tokens-per-minute. Great for prototyping, chat apps and evals.
- Speed is the product. Hundreds of tokens per second on small models. If latency matters more than the absolute frontier, Groq is the comparison everyone makes.
gsk_collides with nothing. Unlike baresk-keys, agsk_key is unambiguous, it can only be Groq.
For anything beyond chat (audio transcription, batch), check the Groq docs; coverage differs from the chat surface.