Skip to main content

Prem AI

The PremEmbeddings class uses the Prem AI API to generate embeddings for a given text.

Setup

In order to use the Prem API you'll need an API key. You can sign up for a Prem account and create an API key here.

You'll first need to install the @langchain/community package:

npm install @langchain/community @langchain/core

Usage

import { PremEmbeddings } from "@langchain/community/embeddings/premai";

const embeddings = new PremEmbeddings({
// In Node.js defaults to process.env.PREM_API_KEY
apiKey: "YOUR-API-KEY",
// In Node.js defaults to process.env.PREM_PROJECT_ID
project_id: "YOUR-PROJECT_ID",
model: "@cf/baai/bge-small-en-v1.5", // The model to generate the embeddings
});

const res = await embeddings.embedQuery(
"What would be a good company name a company that makes colorful socks?"
);
console.log({ res });

API Reference:


Was this page helpful?


You can also leave detailed feedback on GitHub.