agno-lambda-apigateway

Deploy Agno agents as FastAPI REST APIs on AWS Lambda behind API Gateway.

Updated Sep 10, 2026
One-click install
npx skills add https://github.com/allankltsn/setup_kiro --skill agno-lambda-apigateway-allankltsn
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: agno-lambda-apigateway
Source: https://github.com/allankltsn/setup_kiro/tree/main/.kiro/skills/agno-lambda-apigateway
Command: npx skills add https://github.com/allankltsn/setup_kiro --skill agno-lambda-apigateway-allankltsn

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires fastapi, mangum, agno, openai, boto3, uvicorn.

What problem does it solve? Exposing an Agno agent as a production HTTP API on AWS involves many decisions: how to adapt FastAPI to Lambda events, how to package heavy dependencies, how to handle the 29-second API Gateway timeout, and how to manage LLM keys and conversation state in a stateless environment. This Skill provides a complete, opinionated blueprint covering all of these concerns. ## Core Features & Use Cases - Two deployment paths: FastAPI + Mangum with Lambda Layers as the default, or a container image with the AWS Lambda Web Adapter when dependencies exceed the 250 MB limit. - Full SAM infrastructure: template.yaml covering API Gateway, Lambda, Lambda Layer, Secrets Manager, and DynamoDB for sessions and memory. - Response patterns: synchronous requests, streaming via StreamingResponse or response-stream invoke mode, and asynchronous 202 + polling with SQS for long-running agents. - Use Case: You built an Agno chat agent locally and need to ship it as a secured REST endpoint. Follow the Skill to write the FastAPI routes, package dependencies into a Layer, store the OpenAI key in Secrets Manager, persist sessions in DynamoDB, and deploy with sam deploy --guided. ## Quick Start Ask the AI to scaffold a FastAPI app exposing my Agno agent as a POST /chat endpoint and generate the SAM template to deploy it on AWS Lambda behind API Gateway.

Frequently Asked Questions about agno-lambda-apigateway

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I deploy a FastAPI app on AWS Lambda?▼

Wrap the FastAPI app with Mangum, which adapts the ASGI interface to Lambda events, and point the function handler at main.handler. Deploy with AWS SAM using sam build --use-container and sam deploy --guided.

How do I expose an Agno agent as a REST API?▼

Create the Agno agent once at module scope, define FastAPI routes with Pydantic request models, and call agent.run inside the route handler. Publish the app through API Gateway using either Mangum or a container image with the Lambda Web Adapter.

Mangum vs Lambda Web Adapter for FastAPI on Lambda?▼

Mangum is the default when dependencies fit the 250 MB function-plus-layers limit, offering simple packaging and low cold start. The Lambda Web Adapter runs uvicorn in a container image up to 10 GB and supports end-to-end response streaming.

Does API Gateway support streaming responses from Lambda?▼

REST API Gateway does not support streaming and buffers responses. Use a container image with the Lambda Web Adapter or a Lambda Function URL with InvokeMode set to RESPONSE_STREAM, combined with FastAPI StreamingResponse.

What happens when an LLM request exceeds the API Gateway timeout?▼

API Gateway has a hard 29-second limit, so long agent runs fail. Switch to an asynchronous pattern: return 202 with a job_id, process via SQS and a worker Lambda, store results in DynamoDB, and let the client poll a jobs endpoint.

Where should I store LLM API keys for a Lambda function?▼

Store keys in AWS Secrets Manager for production or SSM Parameter Store SecureString for smaller setups, never in versioned environment variables. Load the secret once per container with an lru_cache and grant the function only GetSecretValue on that specific secret.