> ## Documentation Index
> Fetch the complete documentation index at: https://llm-tools.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI

To use the OpenAI embedding models, you need a API key from OpenAI.
You can alternatively use Azure OpenAI to run most of the OpenAI embedding models. Read the [Azure OpenAI](/components/llms/azure-openai) section to learn more about this.

To get started, obtain an API Key from OpenAI. You can do this by visiting their [API Portal](https://platform.openai.com/api-keys).
Once you obtain a key, set it in an environment variable, like so -

```bash theme={null}
OPENAI_API_KEY="<Your key>"
```

## Install OpenAI addon

```bash theme={null}
npm install @llm-tools/embedjs-openai
```

## Usage

```ts theme={null}
import { RAGApplicationBuilder } from '@llm-tools/embedjs';
import { OpenAiEmbeddings } from '@llm-tools/embedjs-openai';
import { HNSWDb } from '@llm-tools/embedjs-hnswlib';

const app = await new RAGApplicationBuilder()
.setEmbeddingModel(new OpenAiEmbeddings({
    model: 'text-embedding-3-large'
}))
```

<Note>
  The following embedding models do not require you to pass a dimension parameter -

  * `text-embedding-3-large`
  * `text-embedding-3-small`
  * `text-embedding-ada-002`

  All other models require you provide one.
</Note>
