Skip to main content


All functionality related to Amazon AWS platform



See a usage example.

from langchain.llms.bedrock import Bedrock

Amazon API Gateway

Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. APIs act as the "front door" for applications to access data, business logic, or functionality from your backend services. Using API Gateway, you can create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications. API Gateway supports containerized and serverless workloads, as well as web applications.

API Gateway handles all the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls, including traffic management, CORS support, authorization and access control, throttling, monitoring, and API version management. API Gateway has no minimum fees or startup costs. You pay for the API calls you receive and the amount of data transferred out and, with the API Gateway tiered pricing model, you can reduce your cost as your API usage scales.

See a usage example.

from langchain.llms import AmazonAPIGateway

api_url = "https://<api_gateway_id>.execute-api.<region>"
# These are sample parameters for Falcon 40B Instruct Deployed from Amazon SageMaker JumpStart
model_kwargs = {
"max_new_tokens": 100,
"num_return_sequences": 1,
"top_k": 50,
"top_p": 0.95,
"do_sample": False,
"return_full_text": True,
"temperature": 0.2,
llm = AmazonAPIGateway(api_url=api_url, model_kwargs=model_kwargs)

SageMaker Endpoint

Amazon SageMaker is a system that can build, train, and deploy machine learning (ML) models with fully managed infrastructure, tools, and workflows.

We use SageMaker to host our model and expose it as the SageMaker Endpoint.

See a usage example.

from langchain.llms import SagemakerEndpoint
from langchain.llms.sagemaker_endpoint import LLMContentHandler

Text Embedding Models


See a usage example.

from langchain.embeddings import BedrockEmbeddings

SageMaker Endpoint

See a usage example.

from langchain.embeddings import SagemakerEndpointEmbeddings
from langchain.llms.sagemaker_endpoint import ContentHandlerBase

Document loaders

AWS S3 Directory and File

Amazon Simple Storage Service (Amazon S3) is an object storage service. AWS S3 Directory AWS S3 Buckets

See a usage example for S3DirectoryLoader.

See a usage example for S3FileLoader.

from langchain.document_loaders import S3DirectoryLoader, S3FileLoader


AWS DynamoDB

AWS DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability.

We have to configure the AWS CLI.

We need to install the boto3 library.

pip install boto3

See a usage example.

from langchain.memory import DynamoDBChatMessageHistory