AWS Builder Center
Build a Tiny AI App with Amazon Bedrock in an Afternoon

Build a Tiny AI App with Amazon Bedrock in an Afternoon

A beginner-friendly tutorial for calling foundation models on Amazon Bedrock from Python, wrapping it in a FastAPI endpoint, and keeping costs under control.

IT Student | Aspiring Software Engineer | DevOps & Cloud Enthusiast | .NET, Angular, Node.js
Everyone is talking about generative AI, but how do you actually use it on AWS? In this tutorial, we'll build a small AI text summarizer API with Amazon Bedrock, Python, and FastAPI — in about an afternoon.

What we're building

A REST endpoint where you send any text, and it returns a short summary generated by a foundation model.
POST /summarize → Amazon Bedrock → short summary

Prerequisites

  • An AWS account with AWS CLI configured ( aws configure )
  • Python 3.10+
  • Basic knowledge of Python

Step 1: Check model access in Bedrock

  1. Open the Amazon Bedrock console in  us-east-1 
  1. Go to Model catalog and pick a model — in this guide we'll use Amazon Nova Lite (fast and cheap)
  1. If your account asks you to enable or request access to the model, do that first
The model ID for Nova Lite is  amazon.nova-lite-v1:0 .

Step 2: Set up the project

mkdir bedrock-summarizer && cd bedrock-summarizer
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install boto3 fastapi uvicorn

Step 3: Call Bedrock from Python

Create  bedrock_client.py :
import boto3

client = boto3.client("bedrock-runtime", region_name="us-east-1")
MODEL_ID = "amazon.nova-lite-v1:0"


def summarize(text: str) -> str:
response = client.converse(
modelId=MODEL_ID,
messages=[
{
"role": "user",
"content": [
{"text": f"Summarize the following text in 3 short bullet points:\n\n{text}"}
],
}
],
inferenceConfig={"maxTokens": 300, "temperature": 0.3},
)
return response["output"]["message"]["content"][0]["text"]
We use the Converse API, which works the same way across different models — so you can switch models by changing only  MODEL_ID .

Step 4: Wrap it in a FastAPI endpoint

Create  main.py :
from fastapi import FastAPI
from pydantic import BaseModel
from bedrock_client import summarize

app = FastAPI(title="Bedrock Summarizer")


class SummarizeRequest(BaseModel):
text: str


@app.post("/summarize")
def summarize_endpoint(req: SummarizeRequest):
return {"summary": summarize(req.text)}

Step 5: Run and test it

uvicorn main:app --reload
Open  http://127.0.0.1:8000/docs  — FastAPI gives you an interactive Swagger UI for free. Paste some long text into  /summarize  and click Execute.
Or with curl:
curl -X POST http://127.0.0.1:8000/summarize \
-H "Content-Type: application/json" \
-d '{"text": "Paste a long paragraph here..."}'

Step 6: Keep costs under control

Bedrock charges per token (input + output). For a small project like this, costs are tiny, but:
  • Use smaller models (like Nova Lite) for simple tasks
  • Set  maxTokens  to limit output length
  • Add a budget alert in Billing so you're never surprised

Ideas to extend it

  1. Try different models — just change  MODEL_ID  and compare quality and speed
  1. Add RAG — use Bedrock Knowledge Bases to answer questions about your own documents
  1. Build an agent — use Bedrock Agents so the model can call your APIs
  1. Deploy it — containerize with Docker and run on ECS Fargate or Lambda

Key takeaways

  • Amazon Bedrock lets you use foundation models through a simple API — no ML infrastructure needed
  • The Converse API makes switching models easy
  • A useful AI feature can be built in an afternoon
What would you build with Bedrock? Share your idea in the comments 👇
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article