Groq API key setup: projects, spend limits and the OpenAI-compatible URL
Create a Groq API key in GroqCloud, keep it on your server as GROQ_API_KEY, put each app in its own project, and set a spend limit before you go live.
The short version
Create a project for your app in the Groq console, select it, open API Keys and create a key. Store it on your host as GROQ_API_KEY and call Groq only from server code, with the groq-sdk package or with the OpenAI SDK pointed at https://api.groq.com/openai/v1. Before real users arrive, move to the paid Developer tier if you need the higher limits, and set a monthly spend limit with email alerts, because Groq bills usage after the fact rather than from a prepaid balance.
Groq is worth a look when speed matters more than having the very strongest model: it runs open models such as Llama, Qwen and OpenAI's open-weight gpt-oss on its own hardware. It is not where you get Claude, GPT or Gemini, so it often sits next to one of those providers rather than replacing it.
Projects decide what a key can touch
Groq groups everything by organization, then by project. Groq's projects guide says any key you generate belongs to the project selected in the top bar at that moment, and that usage, logs and per-model rate limits are tracked per project. That gives you a clean way to keep products apart without separate accounts: one project per product, or one per environment such as myapp-dev and myapp-prod, which is the naming Groq itself suggests.
Project rate limits can only be set lower than your organization's limits, never higher, so they work as a safety brake rather than a way to get more capacity. A development project capped at a handful of requests per minute cannot drain the shared quota that production depends on. Input and output token limits are the exception: Groq enforces those at the organization level only.
Create the key, step by step
- Sign in at console.groq.com. Open the Organization and Projects dropdown at the top left and create a project named after the app.
- With that project selected, open API Keys and create a key. Groq keys start with
gsk_, which makes them easy to spot if one ends up somewhere it should not. - Copy it once into your host's environment variables as
GROQ_API_KEY. Use a separate key for development and production, as Groq's security guide recommends. - Open Manage Projects, choose View, and lower the per-model limits for any project that does not need the full organization quota.
- If you are on the paid tier, go to Settings, Billing, Limits, add a monthly limit in dollars and alerts at 50%, 75% and 90%.
Free tier, Developer tier and how billing works
You can start on the free tier without a card. Upgrading to the Developer tier needs a payment method and raises your rate limits, adds Batch and Flex processing and unlocks spend limits. There is no charge at the moment you upgrade: Groq bills monthly in arrears, and for new accounts it also bills early when lifetime usage first crosses $1, $10, $100, $500 and $1,000, so a surprise first invoice stays small.
The spend limit is useful but has two catches worth knowing. It covers the whole organization, not one key or one project, and Groq's spend figure updates every 10 to 15 minutes, so a busy app can run a little past the limit before requests are blocked with a 400 error and the code blocked_api_access. It also resets on the 1st of each month. That is weaker than OpenRouter, where each key can carry its own credit cap.
| Question | Free tier | Developer tier |
|---|---|---|
| Card needed | No | Yes |
| Spend limits and alerts | Not available | Organization-wide, monthly |
| Batch and Flex processing | No | Yes |
| How you pay | Nothing | Monthly in arrears, plus early invoices at the first thresholds |
Call Groq from the server
Groq says its API is mostly compatible with OpenAI's client libraries, so existing OpenAI code usually needs only a new key and base URL. A few fields are not supported and return a 400 error, including logprobs, logit_bias and messages[].name, and a temperature of 0 is quietly changed to a tiny positive number. If you would rather avoid surprises, use Groq's own groq-sdk package, which takes the same shape of request.
Keep the model name in a variable such as GROQ_MODEL. Groq retires and replaces open models often, and you want that change to be a settings edit rather than a code change. When you hit a limit, Groq returns HTTP 429 with a retry-after header in seconds, so wait that long before trying again.
// app/api/ask/route.ts
import Groq from 'groq-sdk'
const groq = new Groq({ apiKey: process.env.GROQ_API_KEY })
export async function POST(req: Request) {
// Check the session and a per-user rate limit here.
const { question } = await req.json()
const res = await groq.chat.completions.create({
model: process.env.GROQ_MODEL!, // set on your host
messages: [{ role: 'user', content: question }],
})
return Response.json({ text: res.choices[0]?.message?.content ?? '' })
}If the key leaks
Revoke it in the console straight away, create a replacement in the same project, and update your host. Because Groq bills after use, check the usage dashboard for the days the key was exposed, and if you had no spend limit set, add one now. Groq's security guide also asks you to rotate keys on a schedule, for example every quarter, and never to ship a key in browser code: anything the browser needs should go through your own server route like the one above.
What Shipyard does here
Shipyard's AI step currently writes Anthropic, OpenAI or OpenRouter keys into your host, not Groq keys. To use Groq today, add GROQ_API_KEY and GROQ_MODEL to your host yourself after launch, following the steps on this page. If you mostly want cheap, fast open models behind a hard per-key budget, choosing OpenRouter as the provider is the simpler route, and Shipyard writes that key for you on the server side only.
Sources
- GroqDocs: quickstartconsole.groq.com
- GroqDocs: projectsconsole.groq.com
- GroqDocs: spend limitsconsole.groq.com
- GroqDocs: billing FAQsconsole.groq.com
- GroqDocs: OpenAI compatibilityconsole.groq.com
- GroqDocs: rate limitsconsole.groq.com
- GroqDocs: security onboardingconsole.groq.com
Launch in an hour, not a weekend
Shipyard connects your accounts once, then sets up the domain, hosting, database, email and payments for every new product.