groq-typescript  by groq

Access Groq AI models via Node.js and TypeScript

Created 2 years ago
251 stars

Top 99.8% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

The groq-sdk is the official Node.js and TypeScript library for interacting with the Groq REST API. It provides developers with a type-safe and convenient way to integrate Groq's large language models into server-side applications, simplifying API calls and data handling.

How It Works

This library is generated using Stainless, ensuring comprehensive TypeScript definitions for all API requests and responses. It abstracts away the complexities of direct HTTP requests, offering a clean interface for common tasks like chat completions and audio transcriptions. The library includes built-in mechanisms for handling file uploads through various input types and provides robust error management with automatic retries for transient network or server issues.

Quick Start & Requirements

  • Installation: npm install groq-sdk
  • Prerequisites:
    • Node.js 20 LTS or later
    • Deno v1.28.0 or higher
    • Bun 1.0 or later
    • Cloudflare Workers, Vercel Edge Runtime, Nitro v2.6+
    • Jest 28+ (with "node" environment; "jsdom" is not supported)
    • TypeScript 4.9+
    • An API key, typically set via process.env['GROQ_API_KEY'].
  • Browser Support: Enabled by setting dangerouslyAllowBrowser: true during client instantiation, but this exposes API credentials client-side.
  • Links: REST API documentation can be found on console.groq.com.

Highlighted Details

  • Provides full TypeScript definitions for request parameters and response fields, enhancing developer productivity and reducing runtime errors.
  • Supports flexible file uploads via Node.js fs.ReadStream, browser File objects, fetch Responses, or a toFile helper utility.
  • Includes automatic request retries (default 2 attempts) with exponential backoff for common transient errors (e.g., connection errors, timeouts, rate limits, 5xx responses).
  • Configurable request timeouts (default 1 minute) and retry counts.
  • Allows access to raw fetch Response objects via .asResponse() or .withResponse() methods for advanced handling.
  • Offers configurable logging levels and supports integration with custom logging libraries like Pino or Winston.
  • Enables making custom/undocumented requests using direct HTTP verbs (client.get, client.post) and handling undocumented parameters or response properties with // @ts-expect-error.

Maintenance & Community

The README mentions contributing documentation, indicating an active development process. Specific community channels (like Discord/Slack) or notable contributors are not detailed in the provided text.

Licensing & Compatibility

The license type is not specified in the provided README content. Compatibility for commercial use or linking with closed-source projects is therefore undetermined from this information.

Limitations & Caveats

  • Browser support requires explicit configuration (dangerouslyAllowBrowser: true), which poses a security risk by exposing API credentials in client-side code.
  • Jest testing with the "jsdom" environment is explicitly unsupported.
  • React Native is not supported at this time.
Health Check
Last Commit

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
1
Issues (30d)
0
Star History
4 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.