> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stigg.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Groq

> Wrap Groq's own client, or the OpenAI client pointed at Groq, to meter and gate calls with Stigg.

Groq serves open-weight models on its own inference hardware.

## Set up

Wrap either Groq's own client, `Groq` from `groq-sdk`, or an `OpenAI` client whose `baseURL` points at Groq. The SDK recognizes both from the `api.groq.com` address and selects the Groq recipe automatically.

<CodeGroup>
  ```typescript Groq client theme={null}
  import Groq from 'groq-sdk';

  const groq = stigg.wrap(new Groq({ apiKey: process.env.GROQ_API_KEY }));

  await groq.chat.completions.create({
    model: 'llama-3.3-70b-versatile',
    messages,
    stiggContext: { customerId: 'customer-acme', entitlement: { currencyId: 'credits' } },
  });
  ```

  ```typescript OpenAI client theme={null}
  import OpenAI from 'openai';

  const groq = stigg.wrap(
    new OpenAI({ baseURL: 'https://api.groq.com/openai/v1', apiKey: process.env.GROQ_API_KEY }),
  );

  await groq.chat.completions.create({
    model: 'llama-3.3-70b-versatile',
    messages,
    stiggContext: { customerId: 'customer-acme', entitlement: { currencyId: 'credits' } },
  });
  ```
</CodeGroup>

* **Streamed calls are metered without extra options.** Groq sends the usage of a streamed call on its last chunk, and the SDK reads it from there.
* **A Groq address the SDK does not recognize**, such as a proxy in front of Groq, is metered with the OpenAI recipe and reported under `openai.*`. To report it as Groq, pass the recipe yourself: `stigg.wrap(client, { recipe: groqRecipe })`.

<Warning>
  Earlier versions of the SDK reported Groq calls under `openai.chat.completions.create`. They are now reported under `groq.chat.completions.create`. If a meter in Stigg filters on the old event name for Groq traffic, add the new name to it, or pass `recipe: openAIRecipe` to `wrap()` to keep the old name.
</Warning>

## What is reported

Groq returns a `usage` object in OpenAI's format with the number of tokens each call consumed. The wrapper reads it and reports it to Stigg as the metrics below. For details, see Groq's [API reference](https://console.groq.com/docs/api-reference).

| Method | Event name |
| - | - |
| `chat.completions.create` | `groq.chat.completions.create` |

Groq has no Responses API, so it has a single event name.

| Metric | What it counts |
| - | - |
| `prompt_tokens` | Input tokens, **including** cached tokens |
| `completion_tokens` | Output tokens |
| `cached_tokens` | Input tokens served from the cache |
| `total_tokens` | All input and output tokens, as reported by the vendor |

Groq does not return a price, so there is no `cost` metric. Cached tokens are counted **inside** `prompt_tokens`, so price the input or the cached tokens, not both. `total_tokens` includes all the token counts above, so price the total or the parts, never both.

For Groq's compound systems, which run several models in one request, the request's total usage is reported. The per-model breakdown Groq also returns is not reported.

Every usage field the vendor returns is also included, with a `raw.` prefix. See [How usage is reported](/documentation/ai-agents/llm-wrappers/supported-providers#how-usage-is-reported).


## Related topics

- [Supported providers and gateways](/documentation/ai-agents/llm-wrappers/supported-providers.md)
- [OpenAI-compatible endpoints](/documentation/ai-agents/llm-wrappers/providers/openai-compatible.md)
- [Agent SDK](/api-and-sdks/references/sdk/backend/graphql/agent-sdk.md)
- [JavaScript](/api-and-sdks/changelog/agent-sdk/javascript.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.