Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Observable AI Streaming on AWS

Stream structured LLM responses from Bedrock Claude through AWS API Gateway REST, Lambda, and Middy with deferred observability using TransformStream flush(). Built with AI SDK v6.

Blog Series

Companion code for a four-part series on dev.to:

  1. Streaming LLM Responses Through API Gateway REST with Lambda
  2. The Middy After Hook Problem
  3. Deferred Observability with TransformStream flush()
  4. Complete CDK Stack with Tests

Progressive Development

Each step builds on the previous one. Check the PRs to see the delta:

Branch PR Description
step-1/api-gateway-streaming #1 CDK stack, Lambda handler, AI SDK streaming
step-2/stream-error-handling #2 AbortError classification for streaming
step-3/transformstream-observability #3 TransformStream pipeline for deferred observability
step-4/complete-cdk-stack #4 Test suite and production readiness

Quick Start

npm install
npx cdk deploy

Prerequisites

  • Node.js 22+
  • AWS CLI configured
  • AWS CDK CLI
  • Bedrock model access enabled for Claude 3.5 Sonnet v2

Key Patterns

  • TransformStream Pipeline: WHATWG flush() as deferred execution point after stream completion
  • Dual Middleware Bridge: In-memory store connecting AI SDK and Middy middleware systems
  • Deferred Observability: Attach logging to the data pipeline, not the HTTP lifecycle

License

MIT

About

Stream structured LLM responses from Bedrock Claude through AWS API Gateway REST, Lambda, and Middy with deferred observability using TransformStream flush(). Built with AI SDK v6.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages