# Groq (/en/ai/platform/models/llm/groq)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

> Documentation: Conversational AI.
> Documentation version: Preview.
> This document describes only this version. [Version index](/llms/doc-versions-convoai-guides-v2.txt).


Groq provides state-of-the-art language models optimized for different use cases.

## Sample configuration

The following example shows how to configure Groq as the agent's LLM when you create or update an agent. For a complete example, see [Create an agent and start a session](/en/ai/platform/get-started/start-stop-agent#create-an-agent).

Groq supports BYOK only. It isn't available in managed mode. Store your Groq API key in a secret set, and refer to it from the agent. For details, see [Use your own provider keys](/en/ai/platform/build/use-your-own-keys).

**Python SDK**

```python
from agora_agent import Agent, Groq, secret_ref

# client is your configured Agora client
agent = (
    Agent(client=client)
    .with_stt(...)  # configure your ASR vendor
    .with_llm(
        Groq(
            api_key=secret_ref("support_prod", "groq"),
            vendor="groq",
            base_url="https://api.groq.com/openai/v1/chat/completions",
            model="llama-3.3-70b-versatile",
            max_history=32,
            failure_message="Please hold on a second.",
            system_messages=[
                {"role": "system", "content": "You are a friendly support agent for Acme. Keep your answers short."}
            ],
        )
    )
    .with_tts(...)  # configure your TTS vendor
)
```

**TypeScript SDK**

```ts
import { Agent, Groq, secretRef } from 'agora-agents';

// client is your configured Agora client
const agent = new Agent({ client })
  .withStt(/* configure your ASR vendor */)
  .withLlm(
    new Groq({
      apiKey: secretRef('support_prod', 'groq'),
      vendor: 'groq',
      url: 'https://api.groq.com/openai/v1/chat/completions',
      model: 'llama-3.3-70b-versatile',
      maxHistory: 32,
      failureMessage: 'Please hold on a second.',
      systemMessages: [
        { role: 'system', content: 'You are a friendly support agent for Acme. Keep your answers short.' },
      ],
    }),
  )
  .withTts(/* configure your TTS vendor */);
```

**Go SDK**

```go
// client is your configured Agora client
maxHistory := 32
agent := agentkit.NewAgent(client).
	WithStt( /* configure your ASR vendor */ ).
	WithLlm(vendors.NewGroq(vendors.GroqOptions{
		APIKey:         agentkit.SecretRef("support_prod", "groq"),
		Vendor:         "groq",
		BaseURL:        "https://api.groq.com/openai/v1/chat/completions",
		Model:          "llama-3.3-70b-versatile",
		MaxHistory:     &maxHistory,
		FailureMessage: "Please hold on a second.",
		SystemMessages: []map[string]interface{}{
			{"role": "system", "content": "You are a friendly support agent for Acme. Keep your answers short."},
		},
	})).
	WithTts( /* configure your TTS vendor */ )
```

**REST API**

Set `credential.mode` to `byok` and `credential.fields.api_key` to a reference to the key. In the following example, the key is stored as `groq` in the `support_prod` set:

```json
"llm": {
  "credential": {
    "mode": "byok",
    "fields": {
      "api_key": "$secrets.support_prod.groq"
    }
  },
  "vendor": "groq",
  "style": "openai",
  "model": "llama-3.3-70b-versatile",
  "url": "https://api.groq.com/openai/v1/chat/completions",
  "max_history": 32,
  "failure_message": "Please hold on a second."
}
```

Set the system prompt and the greeting with the agent's `instructions` and `greeting`, not in the `llm` block.

## Key parameters

The `llm` block takes the following fields. In the SDKs, the LLM class sets them from its options. Use the `Groq` class. The SDK sets the style to `openai`.

**llm**

**`vendor` (string) required**

Set to `groq`.

**`credential` (object) required**

Set `mode` to `byok` and `fields.api_key` to a `$secrets.<set>.<key>` reference to your Groq API key. Create and manage your API key from [Groq console](https://console.groq.com/keys).

**`style` (string) optional**

Set to `openai`. Groq uses an OpenAI-compatible API.

**`model` (string) required**

Refer to [Groq models](https://console.groq.com/docs/models) for available models.

**`url` (string) required**

Use the completions endpoint.

For complete `llm` block options, see [Create an agent](/en/api-reference/api-ref/conversational-ai/platform/create-agent). For advanced configuration options, model capabilities, and detailed parameter descriptions, see the [Groq API Documentation](https://console.groq.com/docs/api-reference).
