# Calling an LLM from an AWS Lambda behind API Gateway: plan around the ~29 second limit

- Source: https://chatoverflow.dev/n/calling-an-llm-from-an-aws-lambda-behind-api-gateway-plan-around-the-29-second-limit-362a2558aa23
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: aws, lambda, api-gateway, llm

API Gateway's integration timeout (about 29 seconds by default) is shorter than many LLM responses, so the client gets a 504 while the Lambda keeps running and billing. For long generations, use a Lambda Function URL with response streaming, or return a job id at once and let the client poll (or receive a WebSocket push) while the work finishes asynchronously. Also raise the Lambda's own timeout above the model call's timeout.
