---
name: groq-install-auth
description: 'Install and configure Groq SDK authentication for TypeScript or Python.

  Use when setting up a new Groq integration, configuring API keys,

  or initializing the groq-sdk in your project.

  Trigger with phrases like "install groq", "setup groq",

  "groq auth", "configure groq API key".'
allowed-tools: Bash(npm:*), Bash(pip:*), Bash(export:*)
version: 1.11.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
  - saas
  - groq
  - api
  - authentication
compatibility: Designed for Claude Code
title: groq-install-auth
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/groq-install-auth
last_updated: 2026-10-07T06:06:28.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/configuration.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/configuration.md), [references/troubleshooting.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/troubleshooting.md), [references/verification.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/verification.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/groq-install-auth`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/groq-install-auth`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/groq-install-auth) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/groq-install-auth`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/groq-install-auth --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/groq-install-auth --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Groq Install & Auth

## Overview

Install the official Groq SDK and configure API key authentication. Groq provides ultra-fast LLM inference on custom LPU hardware through an OpenAI-compatible REST API at `api.groq.com/openai/v1/`.

The workflow is four steps: install the SDK, mint an API key, export it as an
environment variable, and verify the connection by listing models. Each step is
summarized below; deep detail lives in [`references/`](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references).

## Prerequisites

- Node.js 18+ or Python 3.8+
- Package manager (npm, pnpm, or pip)
- Groq account at [console.groq.com](https://console.groq.com)
- API key from GroqCloud console (Settings > API Keys)

## Instructions

### Step 1: Install the SDK

```bash
set -euo pipefail
# TypeScript / JavaScript
npm install groq-sdk

# Python
pip install groq
```

### Step 2: Get Your API Key

1. Go to [console.groq.com/keys](https://console.groq.com/keys)
2. Click "Create API Key"
3. Copy the key (starts with `gsk_`)
4. Store it securely -- you cannot view it again

### Step 3: Configure Environment

Add the [`.gitignore` template](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/configuration.md#gitignore-template)
**before** writing any `.env` file so a key can never be committed:

```bash
# Set environment variable (recommended)
export GROQ_API_KEY="gsk_your_key_here"

# Or create .env file (add .env to .gitignore first)
echo 'GROQ_API_KEY=gsk_your_key_here' >> .env
```

### Step 4: Verify the Connection

Run a short script that lists the models your key can access — a successful list
proves authentication end-to-end. The essential TypeScript skeleton:

```typescript
import Groq from "groq-sdk";

const groq = new Groq({ apiKey: process.env.GROQ_API_KEY });
const models = await groq.models.list();
console.log(models.data.map((m) => m.id));
```

Full runnable TypeScript **and** Python verification scripts, with expected
output: [verification walkthrough](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/verification.md).

## Output

A successful setup produces:

- `groq-sdk` (Node) or `groq` (Python) installed in the project.
- `GROQ_API_KEY` available in the environment (or `.env`, with `.env` gitignored).
- A verification run that prints the accessible models, for example:

```
Connected! Available models:
  llama-3.3-70b-versatile (owned by Meta)
  llama-3.1-8b-instant (owned by Meta)
```

If the verification run prints a `401` instead of a model list, authentication
failed — see [Error Handling](#error-handling).

## SDK Defaults & Key Formats

The SDK auto-reads `GROQ_API_KEY` from the environment when no `apiKey` is passed.
Groq uses a single `gsk_` key type with full API access (no read/write scopes).
Constructor options (`baseURL`, `maxRetries`, `timeout`), the OpenAI-SDK
compatibility path, and the key-format table are in the
[configuration reference](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/configuration.md).

## Error Handling

| Error | Cause | Solution |
|-------|-------|----------|
| `401 Invalid API Key` | Key missing, revoked, or mistyped | Verify key at console.groq.com/keys |
| `MODULE_NOT_FOUND groq-sdk` | SDK not installed | Run `npm install groq-sdk` |
| `ModuleNotFoundError: No module named 'groq'` | Python SDK missing | Run `pip install groq` |
| `ENOTFOUND api.groq.com` | Network/DNS issue | Check internet connectivity and firewall |

Extended diagnostics (checking the exported variable, `.env` loading, key
rotation): [troubleshooting reference](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/troubleshooting.md).

## Examples

**Example 1 — Node project from scratch:**

```bash
npm install groq-sdk
export GROQ_API_KEY="gsk_your_key_here"
node --env-file=.env verify.mjs   # lists models → auth confirmed
```

**Example 2 — Python project:**

```bash
pip install groq
export GROQ_API_KEY="gsk_your_key_here"
python verify.py                  # prints accessible models
```

**Example 3 — reuse an existing OpenAI codebase:** point the OpenAI SDK at Groq
by overriding `baseURL` to `https://api.groq.com/openai/v1` and passing your
`gsk_` key. See the [configuration reference](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/configuration.md#sdk-defaults).

Complete, runnable versions of the verification scripts are in the
[verification walkthrough](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/verification.md).

## Resources

- [Groq Quickstart](https://console.groq.com/docs/quickstart)
- [Groq API Reference](https://console.groq.com/docs/api-reference)
- [groq-sdk on npm](https://www.npmjs.com/package/groq-sdk)
- [groq-typescript on GitHub](https://github.com/groq/groq-typescript)

## Next Steps

After successful auth, proceed to the `groq-hello-world` skill to run your first
chat completion. For SDK tuning (retries, timeouts, custom base URL), read the
[configuration reference](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/groq-install-auth/references/configuration.md).
