Groq

Run batches on Groq's OpenAI-compatible Batch API.

Groq's Batch API is OpenAI-compatible — same Files API upload, same /batches lifecycle, same JSONL result files — so Batchwork reuses its OpenAI flow almost verbatim. The one wrinkle is the base path.

PropertyValue
ShapeJSONL file upload (OpenAI-compat)
Endpoint/v1/chat/completions
ResultsOutput + error files (JSONL)
WebhooksPoll-only (managed by the server)
Env varGROQ_API_KEY
Package@ai-sdk/groq
Base URLhttps://api.groq.com/openai/v1

Example

import { batch } from "batchwork";
import { groq } from "@ai-sdk/groq";

const job = await batch({
  model: groq("llama-3.3-70b-versatile"),
  requests: [
    { customId: "fr", prompt: "Capital of France? One word." },
    { customId: "jp", prompt: "Capital of Japan? One word." },
  ],
});

How it works

It follows the OpenAI lifecycle exactly: build { custom_id, method, url, body } JSONL lines, upload via the Files API (purpose=batch), create the batch, poll status, then download the output/error files.

Groq is served under /openai/v1, but its batch url must be /v1/chat/completions, so Batchwork strips the /openai prefix from the captured endpoint when creating the batch.

Notes

Groq has no native batch webhook, so it is poll-only. Use the server layer for unified completion events.

Credentials

Set GROQ_API_KEY, or pass apiKey / baseURL / headers to batch(). Install the peer dependency:

bun add @ai-sdk/groq

On this page