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

For anything beyond chat (audio transcription, batch), check the Groq docs; coverage differs from the chat surface.