Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon via a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI. This will help you get started with Amazon Bedrock embedding models using LangChain. For detailed documentation onDocumentation Index
Fetch the complete documentation index at: https://nvd-54.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Bedrock features and configuration options, please refer to the API reference.
概述
集成详情
| Class | Package | Local | Py support | Downloads | Version |
|---|---|---|---|---|---|
Bedrock | @langchain/aws | ❌ | ✅ |
设置
要访问 Bedrock embedding models,你需要create an AWS account, get an API key, and install the@langchain/aws integration package.
Head to the AWS docs to sign up for AWS and setup your credentials. You’ll also need to turn on model access for your account, which you can do by following these instructions.
凭证
如果你想要自动追踪模型调用,还可以设置你的 LangSmith API 密钥,取消注释以下内容:安装
LangChain 的 Bedrock 集成位于@langchain/aws 包中:
实例化
Now we can instantiate our model object and embed text. There are a few different ways to authenticate with AWS - the below examples rely on an access key, secret access key and region set in your environment variables:Indexing and retrieval
Embedding models are often used in retrieval-augmented generation (RAG) flows, both as part of indexing data as well as later retrieving it. For more detailed instructions, please see our RAG tutorials under the Learn tab. Below, see how to index and retrieve data using theembeddings object we initialized above. In this example, we will index and retrieve a sample document using the demo MemoryVectorStore.
Direct usage
Under the hood, the vectorstore and retriever implementations are callingembeddings.embedDocument(...) and embeddings.embedQuery(...) to create embeddings for the text(s) used in fromDocuments and the retriever’s invoke operations, respectively.
You can directly call these methods to get embeddings for your own use cases.
Embed single texts
You can embed queries for search withembedQuery. This generates a vector representation specific to the query:
Embed multiple texts
You can embed multiple texts for indexing withembedDocuments. The internals used for this method may (but do not have to) differ from embedding queries:
Configuring the Bedrock runtime client
You can pass in your own instance of theBedrockRuntimeClient if you want to customize options like
credentials, region, retryPolicy, etc.
API 参考
有关所有 Bedrock 功能和配置的详细文档,请前往 API 参考。将这些文档连接到 Claude、VSCode 等工具,通过 MCP 获取实时答案。

