---
title: Groq | LlamaIndex OSS Documentation
---

## Installation

```
npm i llamaindex @llamaindex/groq
```

## Usage

First, create an API key at the [Groq Console](https://console.groq.com/keys). Then save it in your environment:

Terminal window

```
export GROQ_API_KEY=<your-api-key>
```

The initialize the Groq module.

```
import { Groq } from "@llamaindex/groq";
import { Settings } from "llamaindex";


Settings.llm = new Groq({
  // If you do not wish to set your API key in the environment, you may
  // configure your API key when you initialize the Groq class.
  // apiKey: "<your-api-key>",
});
```

## Load and index documents

For this example, we will use a single document. In a real-world scenario, you would have multiple documents to index.

```
import { Document, VectorStoreIndex } from "llamaindex";


const document = new Document({ text: essay, id_: "essay" });


const index = await VectorStoreIndex.fromDocuments([document]);
```

## Query

```
const queryEngine = index.asQueryEngine();


const query = "What is the meaning of life?";


const results = await queryEngine.query({
  query,
});
```

## Full Example

../../examples/models/groq.ts

## API Reference

- [Groq](/typescript/framework-api-reference/classes/groq/index.md)
