> ## 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.

# AstraDB

[AstraDB](https://www.datastax.com/products/datastax-astra) is a document database with a highly performant vector index powered by Apache Cassandra and available as a managed service.

To use Astra as database -

* [Sign up](https://astra.datastax.com/signup) for an AstraDB account. It is free to sign up and doesn't require a credit card.
* Create a database (this takes a couple of minutes to provision)
* From the database overview page get the API Endpoint and generate an Application Token

## Install AstraDB addon

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

## Usage

<CodeGroup>
  ```ts Example theme={null}
  import { RAGApplicationBuilder } from '@llm-tools/embedjs';
  import { OpenAiEmbeddings } from '@llm-tools/embedjs-openai';
  import { AstraDb } from '@llm-tools/embedjs-astradb';
  import { WebLoader } from '@llm-tools/embedjs-loader-web';

  // set OPENAI_API_KEY in your env
  process.env.OPENAI_API_KEY = "sk-xxx";

  const app = await new RAGApplicationBuilder()
  .setEmbeddingModel(new OpenAiEmbeddings())
  .setModel(SIMPLE_MODELS.OPENAI_GPT4_O)
  .setVectorDatabase(
      new AstraDb({
          endpoint: "<ASTRA_DB_API_ENDPOINT>",
          apiKey: "<ASTRA_DB_APP_TOKEN>",
          collectionName: "documents"
      })
  )
  .build();


  //add data source and start query it
  await app.addLoader(new WebLoader({ urlOrContent: 'https://www.forbes.com/profile/elon-musk' }));
  await app.query('Tell me about Elon Musk');
  ```
</CodeGroup>

<Snippet file="missing-vector-db-tip.mdx" />
