# <img src="https://models.dev/logos/groq.svg" alt="Groq logo" className="inline w-8 h-8 mr-2 align-middle dark:invert dark:brightness-0 dark:contrast-200" />Groq
[EN] Source: https://mastra.ai/models/providers/groq

Access 17 Groq models through Mastra's model router. Authentication is handled automatically using the `GROQ_API_KEY` environment variable.

Learn more in the [Groq documentation](https://console.groq.com/docs/models).

```bash
GROQ_API_KEY=your-api-key
```

```typescript
import { Agent } from "@mastra/core";

const agent = new Agent({
  name: "my-agent",
  instructions: "You are a helpful assistant",
  model: "groq/deepseek-r1-distill-llama-70b"
});

// Generate a response
const response = await agent.generate("Hello!");

// Stream a response
const stream = await agent.stream("Tell me a story");
for await (const chunk of stream) {
  console.log(chunk);
}
```

:::info

Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [Groq documentation](https://console.groq.com/docs/models) for details.

:::

## Models

<ProviderModelsTable
  models={[
  {
    "model": "groq/deepseek-r1-distill-llama-70b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 131072,
    "maxOutput": 8192,
    "inputCost": 0.75,
    "outputCost": 0.99
  },
  {
    "model": "groq/gemma2-9b-it",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 8192,
    "maxOutput": 8192,
    "inputCost": 0.2,
    "outputCost": 0.2
  },
  {
    "model": "groq/llama-3.1-8b-instant",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 131072,
    "maxOutput": 8192,
    "inputCost": 0.05,
    "outputCost": 0.08
  },
  {
    "model": "groq/llama-3.3-70b-versatile",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 131072,
    "maxOutput": 32768,
    "inputCost": 0.59,
    "outputCost": 0.79
  },
  {
    "model": "groq/llama-guard-3-8b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": false,
    "reasoning": false,
    "contextWindow": 8192,
    "maxOutput": 8192,
    "inputCost": 0.2,
    "outputCost": 0.2
  },
  {
    "model": "groq/llama3-70b-8192",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 8192,
    "maxOutput": 8192,
    "inputCost": 0.59,
    "outputCost": 0.79
  },
  {
    "model": "groq/llama3-8b-8192",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 8192,
    "maxOutput": 8192,
    "inputCost": 0.05,
    "outputCost": 0.08
  },
  {
    "model": "groq/meta-llama/llama-4-maverick-17b-128e-instruct",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 131072,
    "maxOutput": 8192,
    "inputCost": 0.2,
    "outputCost": 0.6
  },
  {
    "model": "groq/meta-llama/llama-4-scout-17b-16e-instruct",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 131072,
    "maxOutput": 8192,
    "inputCost": 0.11,
    "outputCost": 0.34
  },
  {
    "model": "groq/meta-llama/llama-guard-4-12b",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": false,
    "reasoning": false,
    "contextWindow": 131072,
    "maxOutput": 128,
    "inputCost": 0.2,
    "outputCost": 0.2
  },
  {
    "model": "groq/mistral-saba-24b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 32768,
    "maxOutput": 32768,
    "inputCost": 0.79,
    "outputCost": 0.79
  },
  {
    "model": "groq/moonshotai/kimi-k2-instruct",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 131072,
    "maxOutput": 16384,
    "inputCost": 1,
    "outputCost": 3
  },
  {
    "model": "groq/moonshotai/kimi-k2-instruct-0905",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 262144,
    "maxOutput": 16384,
    "inputCost": 1,
    "outputCost": 3
  },
  {
    "model": "groq/openai/gpt-oss-120b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 131072,
    "maxOutput": 32768,
    "inputCost": 0.15,
    "outputCost": 0.75
  },
  {
    "model": "groq/openai/gpt-oss-20b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 131072,
    "maxOutput": 32768,
    "inputCost": 0.1,
    "outputCost": 0.5
  },
  {
    "model": "groq/qwen-qwq-32b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 131072,
    "maxOutput": 16384,
    "inputCost": 0.29,
    "outputCost": 0.39
  },
  {
    "model": "groq/qwen/qwen3-32b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 131072,
    "maxOutput": 16384,
    "inputCost": 0.29,
    "outputCost": 0.59
  }
]}
/>

## Advanced Configuration

### Custom Headers

```typescript
const agent = new Agent({
  name: "custom-agent",
  model: {
    url: "https://api.groq.com/openai/v1",
    id: "groq/deepseek-r1-distill-llama-70b",
    apiKey: process.env.GROQ_API_KEY,
    headers: {
      "X-Custom-Header": "value"
    }
  }
});
```

### Dynamic Model Selection

```typescript
const agent = new Agent({
  name: "dynamic-agent",
  model: ({ runtimeContext }) => {
    const useAdvanced = runtimeContext.task === "complex";
    return useAdvanced
      ? "groq/qwen/qwen3-32b"
      : "groq/deepseek-r1-distill-llama-70b";
  }
});
```



## Direct Provider Installation

This provider can also be installed directly as a standalone package, which can be used instead of the Mastra model router string. View the [package documentation](https://www.npmjs.com/package/@ai-sdk/groq) for more details.

```bash npm2yarn copy
npm install @ai-sdk/groq
```

For detailed provider-specific documentation, see the [AI SDK Groq provider docs](https://ai-sdk.dev/providers/ai-sdk-providers/groq).


---
title: "Hugging Face | Models | Mastra"
description: "Use Hugging Face models with Mastra. 14 models available."
---

{/* This file is auto-generated by generate-model-docs.ts - DO NOT EDIT MANUALLY */}