Groq Tutorial: Getting Started the Right Way
Groq runs open-weight models on fast custom hardware via an OpenAI-compatible API. This tutorial covers signup, API keys, and your first call.
By Galactic News Editorial · Published 2026-11-09T19:27:33+00:00 · Updated 2026-11-09T19:27:33+00:00
Groq Tutorial: Getting Started the Right Way
Groq runs open-weight language models on custom hardware built for fast inference. Its API is OpenAI-compatible. That means code you already wrote for OpenAI can move to Groq with a base URL change. This Groq tutorial shows the right way to start. You will create an account, make a key, send your first request, and pick a model that is actually available.
The whole setup takes a few minutes. The mistakes take longer to fix. Keys get pasted into code. Old model names get copied from stale guides. Rate limits surprise new users. This guide helps you avoid all three.
What Groq Is and What It Is Not
Groq is an inference company. It does not train its own flagship models. It runs open-weight models from others, such as Meta's Llama family, Alibaba's Qwen, and OpenAI's GPT-OSS models, on its own Language Processing Units. These chips are built for inference speed, not for training.
Groq is not the same as Grok. Grok is the chatbot from xAI. The names look alike. The companies are different. Do not mix them up when you search for docs or sign up.
Groq exposes its service through a standard cloud API. The API is OpenAI-compatible. The base URL is https://api.groq.com/openai/v1. If your code already uses the OpenAI SDK, you change one string. You do not need to learn a new client library. Groq also publishes its own Python SDK if you prefer it.
Step 1: Create Your Account at the Groq Console
Go to console.groq.com. Click sign up. You can sign in with email, GitHub, or Google. There is no payment screen at sign-up. Groq offers a free tier with no credit card required. The free tier is governed by per-model rate limits. Limits apply at the organization level, not per key. Multiple keys under one organization share the same limits.
Verify your email if asked. Then open the console dashboard. Take a minute to look around. Find the API Keys section in the sidebar. Find the documentation link. Find the usage page. Knowing where these live now saves time later when something fails.
Step 2: Create an API Key and Store It Safely
Open the API Keys section. Click Create API Key. Give the key a clear name, such as laptop-dev or my-first-app. A clear name lets you revoke one key later without breaking everything else. Click create.
The key appears once. It starts with gsk_ followed by a long string. Copy it now. You cannot see it again later. If you lose it, you must delete it and create a new one. That is by design. It limits the damage if a key leaks.
Store the key as an environment variable named GROQ_API_KEY. Do not paste it into your source code. Do not commit it to a repository. Do not share it in a screenshot or a chat message. On macOS or Linux, add this line to your shell config file:
export GROQ_API_KEY="gsk_your_key_here"
Then reload your shell or restart your terminal. From now on, any tool that reads GROQ_API_KEY from the environment will pick it up. This approach keeps the key out of your code. It also keeps it out of your version history, where it is hardest to remove.
Step 3: Send Your First Request With curl
Test the key before you build anything on it. The fastest test is a curl call to the chat completions endpoint. Run this in your terminal:
curl https://api.groq.com/openai/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $GROQ_API_KEY" -d '{"model": "openai/gpt-oss-120b", "messages": [{"role": "user", "content": "Say hello in one sentence."}]}'
A working key returns a JSON response with a reply. A 401 error means the key string is wrong. Check for extra spaces or a missing character. A 403 error means the key is real but not entitled to that model. A 429 error means you hit a rate limit. Wait and retry. A 5xx error means the problem is on Groq's side. Check Groq's status page before you change your code.
If the curl call works, your account, key, and network path are all fine. If it fails, fix it now. Debugging is much harder inside a full application.
Step 4: Make Your First Call in Python
Python gives you two paths. The first uses Groq's own SDK. Install it with pip:
pip install groq
The official library supports Python 3.10 and above. The second path reuses the OpenAI SDK. Point its base URL at Groq. This path needs no new library. Pick one path and stay with it.
Here is a minimal call with the OpenAI SDK:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_GROQ_API_KEY",
base_url="https://api.groq.com/openai/v1",
)
response = client.chat.completions.create(
model="openai/gpt-oss-120b",
messages=[{"role": "user", "content": "Explain inference in one sentence."}],
)
print(response.choices[0].message.content)
Read the key from the environment instead of hardcoding it. Use os.environ for that. The code stays the same across machines. Only the environment changes.
Step 5: Pick a Model From the Live Models Page
Do not copy model names from old guides. Groq's catalog changes. Models get deprecated. Some move to enterprise-only access. Check the live models page at console.groq.com/docs/models before you pick one.
As of the latest check, openai/gpt-oss-120b is a production model. The models page lists it at $0.15 input and $0.60 output per 1 million tokens. The page also lists Llama 3.3 70B as enterprise-only, with contact sales for pricing. Older guides that use llama-3.3-70b-versatile as the default will fail on free and developer keys. That model left the self-serve catalog in August 2026.
You can also list active models with the API itself:
curl https://api.groq.com/openai/v1/models -H "Authorization: Bearer $GROQ_API_KEY"
Preview models are for evaluation only. Groq says they can be discontinued at short notice. Do not build production features on a preview model. Pick a production model for anything real.
Groq Tutorial: Models and Endpoints at a Glance
| Item | What to know |
|---|---|
| Base URL | https://api.groq.com/openai/v1 |
| Models endpoint | GET /openai/v1/models lists active models |
| Production model example | openai/gpt-oss-120b, listed at $0.15 input and $0.60 output per 1M tokens |
| Enterprise-only example | Llama 3.3 70B (llama-3.3-70b-versatile), contact sales |
| Speech to text | Whisper models are available for transcription |
| Key format | Starts with gsk_, shown once at creation |
| Rate limits | Per model, shared at the organization level |
Check the models page again before launch day. Prices and availability change. A model that works in testing can still move tiers before you ship.
Step 6: Handle Errors and Rate Limits Like a Developer
Rate limits are per model. Each model has its own requests-per-minute and tokens-per-minute cap. A small model allows more calls than a large one. Design for this. Add a retry with a short wait when you get a 429 response. Do not hammer the API in a tight loop. That turns a short limit into a long one.
Keep your prompts short while you learn. Short prompts use fewer tokens. They also return faster. Test with one request at a time. Then test with ten. Then test with your real workload. Each step shows you a different limit.
Log the model name and the error code with every failure. When you ask for help, those two facts matter most. "It broke" helps no one. "gpt-oss-120b returned 429 after 40 requests" points straight at the cause.
Common Beginner Mistakes to Avoid
- Hardcoding the API key in source code. Use the GROQ_API_KEY environment variable.
- Copying a model name from an old guide. Check the live models page first.
- Building on a preview model. Preview models can vanish at short notice.
- Ignoring the 429 response. Add a retry with a wait instead of looping fast.
- Confusing Groq with Grok. They are different companies with different products.
- Skipping the curl test. Test the key alone before you test your whole app.
Bottom Line
Getting started with Groq the right way means four things. Create the account at console.groq.com. Make a key and store it as GROQ_API_KEY. Test it with one curl call. Pick your model from the live models page, not from an old guide. After that, the API feels familiar, because it speaks OpenAI's protocol. Your existing code moves over with a base URL change. Build small, watch the limits, and check the catalog before you ship.