npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

groq-browserbase-client

v0.1.4

Published

Groq client implementation for Stagehand

Readme

groq-browserbase-client

A Groq client implementation for Stagehand.

npm version GitHub

Using with Stagehand

This client is designed to work seamlessly with Stagehand for AI-powered web automation. The examples use Qwen 2.5 32B, which has a 128k token context window and excellent capabilities for tool calling and structured outputs:

import { Stagehand } from '@browserbasehq/stagehand';
import { GroqClient } from 'groq-browserbase-client';

// Create the Groq client
const llmClient = new GroqClient({
  modelName: 'qwen-2.5-32b',
  clientOptions: {
    apiKey: process.env.GROQ_API_KEY,
  },
});

// Initialize Stagehand with the Groq client
const stagehand = new Stagehand({
  llmClient,
  env: 'LOCAL',
  headless: false,
  verbose: true,
});

// Use Stagehand's natural language commands
await stagehand.act('Go to example.com and click the login button');
const data = await stagehand.extract('Get all product names from the page');
const elements = await stagehand.observe('What interactive elements are visible?');

Installation

npm install groq-browserbase-client

Usage

Configuration Options

The GroqClient constructor accepts the following options:

{
  modelName: string;           // The Groq model to use
  clientOptions: {
    apiKey?: string;          // Your Groq API key
    baseURL?: string;         // Custom API URL (optional)
    maxRetries?: number;      // Number of retries for failed requests (default: 2)
    timeout?: number;         // Request timeout in ms (default: 60000)
    skipTokenLimitCheck?: boolean; // Skip token limit validation (default: false)
  };
  enableCaching?: boolean;    // Enable response caching (default: false)
  cache?: LLMCache;          // Custom cache implementation
}

Token Limit Handling

The client includes built-in token limit validation to help prevent errors when using Groq models:

  • Known models have predefined token limits based on their specifications
  • Unknown models use a conservative default limit of 8,192 tokens
  • Token limit validation can be disabled using skipTokenLimitCheck: true in client options

Example with token limit validation disabled:

const client = new GroqClient({
  modelName: 'new-groq-model',
  clientOptions: {
    apiKey: 'your-groq-api-key',
    skipTokenLimitCheck: true, // Disable token limit validation
  }
});

Features

  • Full support for Groq API features
  • Compatible with Stagehand's LLM interface
  • Proper error handling and retries
  • Optional response caching
  • Support for structured outputs using response models
  • Automatic handling of token limits and parameter validation
  • Flexible model support with safe defaults for new models

Testing

The package includes comprehensive test coverage for all major functionality:

Coverage Statistics

----------|---------|----------|---------|---------|---------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s   
----------|---------|----------|---------|---------|---------------------
All files |    95.9 |    77.14 |     100 |   96.38 |                     
 index.ts |    95.9 |    77.14 |     100 |   96.38 | 212,523,687-690,714 
----------|---------|----------|---------|---------|---------------------

Test Suites

  • Integration Tests: End-to-end testing of the GroqClient functionality

    • API interaction and response handling
    • Error handling and retries
    • Parameter validation
    • Token limit validation
    • Caching behavior
    • Response model handling
    • Tool call generation and parsing
  • System Prompt Tests: Dedicated test suite for system prompt functionality

    • Basic system prompt handling
    • User instruction integration
    • Message content handling
    • Special character handling
    • Mixed content type support

Running Tests

# Run tests with coverage report
npm run test:coverage

# Run tests in watch mode
npm run test

License

MIT