Skip to main content


The TencentHunyuanEmbeddings class uses the Tencent Hunyuan API to generate embeddings for a given text.


  1. Sign up for a Tencent Cloud account here.
  2. Create SecretID & SecretKey here.
  3. Set SecretID and SecretKey as environment variables named TENCENT_SECRET_ID and TENCENT_SECRET_KEY, respectively.
npm install @langchain/community

If you are using LangChain.js in a browser environment, you'll also need to install the following dependencies:

npm install crypto-js

And then make sure that you import from the web as shown below.


Here's an example:

// in nodejs environment
import { TencentHunyuanEmbeddings } from "@langchain/community/embeddings/tencent_hunyuan";

// in browser environment
// import { TencentHunyuanEmbeddings } from "@langchain/community/embeddings/tencent_hunyuan/web";

/* Embed queries */
const embeddings = new TencentHunyuanEmbeddings();
const res = await embeddings.embedQuery("δ½ ε₯½οΌŒδΈ–η•ŒοΌ");
/* Embed documents */
const documentRes = await embeddings.embedDocuments(["δ½ ε₯½οΌŒδΈ–η•ŒοΌ", "再见"]);
console.log({ documentRes });

API Reference:

Was this page helpful?

You can also leave detailed feedback on GitHub.