Skip to main content

Gradient AI

The GradientEmbeddings class uses the Gradient AI API to generate embeddings for a given text.


You'll need to install the official Gradient Node SDK as a peer dependency:

npm i @gradientai/nodejs-sdk

You will need to set the following environment variables for using the Gradient AI API.


Alternatively, these can be set during the GradientAI Class instantiation as gradientAccessKey and workspaceId respectively. For example:

const model = new GradientEmbeddings({
gradientAccessKey: "My secret Access Token"
workspaceId: "My secret workspace id"


import { GradientEmbeddings } from "@langchain/community/embeddings/gradient_ai";

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

API Reference:

Help us out by providing feedback on this documentation page: