> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Baidu qianfan integration

> Integrate with the Baidu qianfan embedding model using LangChain JavaScript.

The `BaiduQianfanEmbeddings` class uses the Baidu Qianfan API to generate embeddings for a given text.

## Setup

An API key is required to use this embedding model. You can get one by registering at [https://cloud.baidu.com/doc/WENXINWORKSHOP/s/alj562vvu](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/alj562vvu).

Please set the acquired API key as an environment variable named BAIDU\_API\_KEY, and set your secret key as an environment variable named BAIDU\_SECRET\_KEY.

Then, you'll need to install the [`@langchain/baidu-qianfan`](https://www.npmjs.com/package/@langchain/baidu-qianfan) package:

<Tip>
  See [this section for general instructions on installing LangChain packages](/oss/javascript/langchain/install).
</Tip>

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/baidu-qianfan @langchain/core
```

## Usage

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { BaiduQianfanEmbeddings } from "@langchain/baidu-qianfan";

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

## Related

* Embedding model [conceptual guide](/oss/javascript/integrations/embeddings)
* Embedding model [how-to guides](/oss/javascript/integrations/embeddings)

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/embeddings/baidu_qianfan.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
