Use the Groq API from the command line
Groq runs open models such as Llama very fast and has a free tier. Here’s how to use it from the terminal without writing any code.
Quick version with curl
Section titled “Quick version with curl”Groq’s API is OpenAI-compatible, so a raw request looks like this:
curl https://api.groq.com/openai/v1/chat/completions \ -H "Authorization: Bearer $GROQ_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "llama-3.3-70b-versatile", "messages": [{"role": "user", "content": "Explain DNS in one paragraph"}]}'That works, but you get raw JSON back, no conversation memory and no idea what it cost. A CLI makes it pleasant.
With kunji
Section titled “With kunji”pip install kunjikunji keys add groqGet a key at console.groq.com/keys and paste it when asked. It’s stored in your OS keychain. Then:
kunji chat -m groq:llama-3.3-70b-versatileEvery answer streams as it’s generated and ends with a line like:
llama-3.3-70b-versatile · 60 in · 17 out · <$0.0001 · 0.2sMake it your default so you don’t need -m:
kunji use groq:llama-3.3-70b-versatileList the models your key can use:
kunji models groqIn scripts and pipes
Section titled “In scripts and pipes”kunji ask -m groq:llama-3.3-70b-versatile "summarize this" -f notes.txtgit log --oneline -20 | kunji ask "write release notes from these commits"tail -100 server.log | kunji @explainWhen output is piped, kunji prints plain text, so it’s safe to use in scripts. In CI, set the key as an environment variable instead of using the keychain:
export GROQ_API_KEY=...Groq as a fast fallback
Section titled “Groq as a fast fallback”If your main provider is rate-limited or down, kunji can retry on Groq automatically:
kunji config set fallback '["groq:llama-3.3-70b-versatile"]'See Fallback models.
How fast is it, really?
Section titled “How fast is it, really?”Compare it with your other models on the same prompt:
kunji compare "explain big-O notation" -m groq:llama-3.3-70b-versatile -m openai:gpt-4o-miniThe summary table marks the fastest and cheapest. See Compare models.