Generative AI RAG Assistant on AWS

A grounded generative AI request path using API Gateway, Lambda, OpenSearch vector retrieval, Amazon Bedrock, and an S3 knowledge source.

Explore diagram

Explore on mobile. Create and edit manually or with AI on a computer.

AWS retrieval-augmented generation architecture diagram with API Gateway, Lambda, S3, OpenSearch vector search, and Amazon BedrockExplore diagram

AWS retrieval-augmented generation architecture diagram with API Gateway, Lambda, S3, OpenSearch vector search, and Amazon Bedrock. Open the image to explore this ready-made diagram.

Overview

API Gateway receives assistant requests and invokes a Lambda orchestrator. An ingestion Lambda indexes S3 knowledge documents in OpenSearch. The request orchestrator retrieves relevant passages from that index, then supplies that context to an Amazon Bedrock foundation model for grounded response generation.

Components

  • Assistant API and RAG Orchestrator: API Gateway receives requests while Lambda coordinates retrieval and model invocation.
  • Knowledge Documents and Vector Index: S3 preserves source material and OpenSearch serves similarity searches over indexed passages.
  • Amazon Bedrock: A managed foundation model produces the final response from the prompt and retrieved context.

Grounded Answer Flow

  1. A user sends a question to the managed assistant API.
  2. Lambda converts the question into a retrieval request and queries the OpenSearch vector index.
  3. The retrieved passages are supplied to Amazon Bedrock as grounding context for generation.

Customize First

  • Choose an embedding model, chunk size, and metadata-filtering strategy for the document corpus.
  • Add Cognito or an enterprise identity provider before exposing private knowledge.
  • Add evaluation, prompt safety, and citation checks before production rollout.

Related AWS guides

Use these practical explanations to compare services, failure boundaries, and operating tradeoffs before adapting the architecture.

Design rationale

Decisions that shape this architecture

1

Keep orchestration outside the model

Lambda owns retrieval, prompt assembly, authorization context, and response handling so the foundation model remains one replaceable capability in the request path.

2

Preserve source documents separately from the index

S3 retains versioned knowledge artifacts while OpenSearch holds a rebuildable vector projection. The index can be recreated without becoming the only copy of source truth.

3

Ground each response before generation

The orchestrator retrieves the most relevant passages first and sends bounded context to Bedrock, which reduces unsupported answers and makes citations possible.

Before production

Operational checks

Measure retrieval precision and answer quality with a representative evaluation set.

Record document version, retrieved passage IDs, model ID, and prompt version per response.

Apply tenant and document authorization before vector results reach the model prompt.

Set token, latency, concurrency, and cost budgets for the synchronous request path.

Scope and tradeoffs

What this diagram does not solve

Document ingestion is intentionally outside the request path

Chunking, embedding, deletion, and re-indexing need a separate controlled workflow with lineage and failure handling.

Grounding does not eliminate model risk

The application still needs evaluation, safety controls, citation checks, privacy review, and user-visible handling for uncertain answers.

Common questions

Frequently asked questions

Why use OpenSearch in a RAG architecture?

OpenSearch can store vector embeddings and retrieve passages similar to a user query, giving the model relevant private context before it generates an answer.

Where should document embeddings be created?

Create them in a separate ingestion workflow that tracks document versions, chunking rules, embedding model versions, and index updates.

Can this diagram use another vector database?

Yes. Open the editable architecture and replace OpenSearch with the vector store that fits your scale, retrieval features, network model, and operations requirements.

Keep exploring

Explore the library
Serverless multi-tenant SaaS AWS architecture diagram with CloudFront, WAF, Cognito, API Gateway, Lambda, EventBridge, SQS, DynamoDB Streams, and S3
SaaS Backendadvanced

Serverless Multi-Tenant SaaS Architecture on AWS

This architecture combines a protected synchronous API with a durable asynchronous work path. Tenant identity travels from Cognito into application authorization, domain events decouple background work, and DynamoDB plus S3 provide scalable tenant state and assets.

Explore the architecture
AWS batch inference diagram with EventBridge, Step Functions, private VPC compute, job definitions, ECR, SageMaker model registry, and S3 inputs and predictions
ML Platformadvanced

Machine Learning Batch Inference Platform on AWS

This architecture runs scheduled or on-demand scoring as a durable workflow. Step Functions coordinates jobs, AWS Batch supplies container compute, ECR pins the runtime, an approved SageMaker model supplies the artifact, and S3 preserves inputs and predictions.

Explore the architecture
GraphQL AWS diagram with AppSync, Lambda resolvers writing DynamoDB and reading OpenSearch, and a DynamoDB Streams indexing path
Application APIintermediate

Serverless GraphQL API on AWS

This GraphQL architecture separates the client-facing schema, application logic, transactional write model, and asynchronous search model. The split keeps user mutations fast while making OpenSearch replaceable and rebuildable from durable DynamoDB records and change events.

Explore the architecture

Ready-made AWS diagram

Explore this AWS architecture

Open the diagram from this guide and explore how it works. Create and edit manually or with AI on a computer.

Explore diagram