The `groq-sdk` package provides the official TypeScript library for interacting with the Groq API, offering convenient access to Groq's REST API from both server-side TypeScript and JavaScript environments. It is currently at stable version `1.1.2`, released on 2026-03-25. The library exhibits a rapid release cadence, with frequent minor versions and patches, often coinciding with updates to the underlying Groq API. Key differentiators include comprehensive TypeScript support with precise type definitions for all request parameters and response fields, ensuring a robust and type-safe development experience. The SDK is generated using Stainless and includes extensive documentation via docstrings. It supports various methods for file uploads, including `File` instances, `fs.ReadStream`, `fetch` `Response` objects, and a dedicated `toFile` helper for diverse environments.
npm install groq-sdkVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the Groq client with an API key from environment variables and sends a chat completion request to an LLM, including basic error handling for API-specific errors.
Thoroughly review the official migration guides and documentation for `v1.0.0` when upgrading from versions prior to `1.0.0`. Update import statements and object structures as necessary.
Ensure `process.env['GROQ_API_KEY']` is correctly set, or pass the `apiKey` property directly to the `Groq` client constructor: `new Groq({ apiKey: 'YOUR_API_KEY' })`.Use `import Groq from 'groq-sdk';` instead of `const Groq = require('groq-sdk');` for all module imports to ensure compatibility and correct type inference.Set the `GROQ_API_KEY` environment variable (e.g., `export GROQ_API_KEY='sk-...'`) or explicitly pass `apiKey: 'YOUR_SECRET_KEY'` to the `Groq` client constructor.
Change your import statement from `const Groq = require('groq-sdk');` to `import Groq from 'groq-sdk';`.Verify that your `GROQ_API_KEY` is correct, active, and has the necessary permissions. Regenerate the key if necessary from the Groq console.
No dependency data recorded yet.