How aws-samples/bedrock-access-gateway works
Project Type and Purpose
• This is a backend proxy service providing OpenAI-compatible RESTful APIs for Amazon Bedrock models.
• It’s a serverless/containerized microservice that can be deployed either as Lambda functions behind API Gateway (for SSE streaming) or as a Fargate service behind an ALB.
• Its goal is to let OpenAI SDKs and tools work against Bedrock without code changes.
File Structure Analysis
• Top-level directories:
– deployment: CloudFormation templates for API Gateway+Lambda and ALB+Fargate
– src: application code and Dockerfiles
– scripts: helper scripts (push images to ECR)
– docs: supplemental guides (Usage, Troubleshooting, Security)
• src/api: Python FastAPI application
– app.py: main entrypoint
– auth.py: API key validation
– routers/: chat, embeddings, model endpoints
– models/: SQLAlchemy or Pydantic models for Bedrock interactions
– schema.py, setting.py: request/response schemas and config
• src/Dockerfile, Dockerfile_ecs: build images for Lambda and ECS
• deployment templates reference the container image URIs, Secrets Manager ARN, and default model settings
README Insights
• Describes two deployment options:
– API Gateway + Lambda (streaming SSE via Lambda Web Adapter)
– ALB + Fargate (low-latency, no cold starts)
• Features: streaming, chat, embeddings, multimodal, prompt caching, inference profiles