Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Tools · Function

createGroq

Creates a customized Groq provider for the Vercel AI SDK. Configure credentials and the API endpoint, then call the provider with a Groq model identifier.

How it works

createGroq builds a Groq provider instance from optional settings. The resulting provider can be called with a model identifier to obtain a language model, while configuration can customize credentials and the API endpoint prefix.

Syntax

createGroq(options?: GroqProviderSettings): GroqProvider

Parameters

NameTypeDescription
optionsGroqProviderSettingsOptional provider settings, including apiKey and baseURL.

Returns

A Groq provider instance that can create language models from model identifiers.

Key points

  • Import createGroq from the Groq provider package when the default provider instance is not sufficient.
  • Call createGroq with a configuration object to create a customized provider.
  • Without a custom endpoint, requests use Groq's OpenAI-compatible API prefix.
  • The configured API key is sent in the Authorization header.

Common mistakes

  • If apiKey is omitted, the provider uses GROQ_API_KEY from the environment.
  • Set baseURL when requests must go through a proxy or another compatible endpoint.

Example: Create a configured Groq provider

import { createGroq } from '@ai-sdk/groq';

const groq = createGroq({
  apiKey: process.env.GROQ_API_KEY,
});

const model = groq('llama-3.1-8b-instant');

Creates a configured Groq provider and selects a model from it.

When to use it

Custom authentication

Use custom credentials instead of relying on the default environment variable.

Custom API endpoint

Route Groq-compatible requests through a proxy or alternate endpoint.

Multiple configurations

Create separate provider instances with different settings.

  • groq
  • @ai-sdk/groq
  • baseURL
  • apiKey

Source: Groq. Checked 2026-10-15.