Skip to content
Tutorials Center
My learning

Topics

Lesson 59 of 70 ยท Machine learning and IoT

SageMaker and AWS AI Services

A practical map of AWS machine learning: SageMaker build, train and deploy, endpoint types, Amazon Bedrock, and ready-made AI services such as Rekognition, Comprehend, Transcribe and Polly.

You can use machine learning on AWS at three levels, and picking the right one first saves months of work.

  1. Call a ready-made AI service. You send an image, a sound file or a text, and AWS sends back labels, a transcript or a translation. No model knowledge needed.
  2. Call a foundation model. Amazon Bedrock gives API access to large language and image models, which you can combine with your own data.
  3. Build and train your own model. Amazon SageMaker is the platform for data scientists: notebooks, training jobs on rented GPUs, and hosting for the finished model.

This lesson tours all three levels, shows what the calls look like, and gives you a decision rule. It does not teach machine learning itself. If you want that, see the Machine Learning tutorial.

None of these services can run on this site. The boto3 and CLI snippets are real, read-only examples that need an AWS account and permissions. The Python programs are stand-ins: a service chooser and an endpoint cost comparison with invented prices.

Level 1: managed AI services

These services expose trained models through simple APIs. You pay per request, per image or per minute of audio, and there is nothing to deploy.

Service What it does
Rekognition Detects objects, faces, text and unsafe content in images and video
Textract Extracts text, tables and form fields from scanned documents
Comprehend Language analysis: sentiment, entities, key phrases, language detection, PII detection
Translate Machine translation between many languages
Transcribe Speech to text, with speaker labels and custom vocabularies
Polly Text to speech with natural voices
Lex Builds voice and text chatbots (the technology behind Alexa-style dialogs)
Forecast and Personalize Time-series forecasting and recommendations (check current availability before planning around them)

A typical call is a few lines. Here Rekognition labels a photo that is already in S3 (read-only):

Python
import boto3

rekognition = boto3.client("rekognition", region_name="eu-west-1")
response = rekognition.detect_labels(
    Image={"S3Object": {"Bucket": "my-photos", "Name": "beach.jpg"}},
    MaxLabels=5,
    MinConfidence=80,
)
for label in response["Labels"]:
    print(label["Name"], round(label["Confidence"], 1))

Transcribe works as a job, because audio can be long:

Terminal
aws transcribe start-transcription-job \
  --transcription-job-name meeting-2026-11-10 \
  --language-code en-US \
  --media MediaFileUri=s3://my-recordings/meeting.mp3 \
  --output-bucket-name my-transcripts

These services combine well with Lambda and S3 events: an upload triggers a function that calls the service and stores the result. The image pipeline project uses the same pattern.

Level 2: Amazon Bedrock

Amazon Bedrock is a managed service that offers many foundation models (text, chat, image and embedding models from several providers, including Amazon's own) behind one API. You do not manage servers or GPUs, and by default your prompts and outputs are not used to train the base models. You enable access to the models you want in the console, then call them. The Converse API gives one request shape for chat models (read-only):

Python
import boto3

bedrock = boto3.client("bedrock-runtime", region_name="us-east-1")
reply = bedrock.converse(
    modelId="<a model ID you have enabled>",
    messages=[{"role": "user", "content": [{"text": "Explain a VPC in two sentences."}]}],
    inferenceConfig={"maxTokens": 200, "temperature": 0.2},
)
print(reply["output"]["message"]["content"][0]["text"])

Model IDs and availability differ by Region and change often, so take the ID from the Bedrock console instead of copying one from an article. Bedrock adds building blocks around the models:

  • Knowledge Bases connect a model to your documents with retrieval-augmented generation (RAG): documents are split, turned into embeddings, stored in a vector store, and the best passages are added to the prompt.
  • Agents let a model call your APIs and Lambda functions to complete tasks.
  • Guardrails filter harmful content, deny topics and mask personal data in prompts and answers.
  • Fine-tuning and custom models adapt a supported model to your data when prompting is not enough.

Level 3: Amazon SageMaker

Amazon SageMaker AI covers the whole life of your own model. The three verbs are build, train, deploy.

Build. SageMaker Studio and notebook instances give data scientists a managed JupyterLab. JumpStart offers pre-trained models and example solutions you can deploy or fine-tune. Data usually comes from S3, and you can label it with Ground Truth.

Train. A training job starts the compute you ask for (for example one GPU instance), pulls your data and a training container from S3 and ECR, runs your script, writes the model artifact (model.tar.gz) back to S3, and shuts the instances down. You pay only for the job's seconds. Managed Spot training can cut the price when your job saves checkpoints. Hyperparameter tuning jobs run many trainings and keep the best.

Deploy. An endpoint hosts the model behind an HTTPS API. The main flavors:

Endpoint type Use it for
Real-time Steady traffic that needs answers in milliseconds. Instances run all the time.
Serverless inference Spiky or rare traffic. Scales to zero, but cold starts add latency.
Asynchronous Large payloads or long processing. Requests are queued, results land in S3.
Batch transform Scoring a whole dataset offline, with no endpoint running afterwards.

Around these sit Pipelines (a workflow for data prep, training, evaluation and deployment), the Model Registry (versions and approvals) and Model Monitor (detects drift in live data).

Calling a deployed endpoint is a single API call (read-only):

Python
import boto3, json

runtime = boto3.client("sagemaker-runtime", region_name="eu-west-1")
response = runtime.invoke_endpoint(
    EndpointName="churn-model-v3",
    ContentType="application/json",
    Body=json.dumps({"tenure_months": 5, "support_tickets": 4}),
)
print(json.loads(response["Body"].read()))

Choosing the level

The rule is to start at the highest level that does the job.

Python Which level fits the task?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The cost of an endpoint

A real-time SageMaker endpoint bills every hour it exists, even with no requests. That surprises many beginners, and a forgotten notebook or endpoint is a classic cause of a large bill (see Cost Management). This stand-in compares options with invented prices.

Python Always-on endpoint or serverless?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The break-even point depends on real prices, model size and latency needs, so measure before you decide.

Good habits

  • Delete what you are not using: stop notebooks, delete test endpoints. Tag them so Cost Explorer can attribute spend.
  • Least privilege: give the endpoint and training roles access only to the buckets and keys they need. See IAM policies.
  • Keep data private: use VPC endpoints for S3 and the services, and encrypt with KMS.
  • Check responsible-use rules: face recognition and automated decisions about people have legal and ethical limits. Read the service terms.
  • Prototype with managed services first. Training your own model is worth the effort only when no service gives acceptable accuracy.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. You need to extract fields and tables from scanned invoices. Which service is the best first choice?

    Textract is the ready-made service for documents, forms and tables. Building your own model is only worth it if the managed service is not accurate enough.
  2. 2. What does Amazon Bedrock provide?

    Bedrock is a managed way to call foundation models, with features around them such as retrieval over your documents, agents and content filters.
  3. 3. Which SageMaker endpoint type scales to zero when there are no requests?

    Serverless inference only charges while handling requests, at the price of cold starts. Real-time endpoints keep instances running and bill every hour.
  4. 4. What happens at the end of a SageMaker training job?

    The job saves the model artifact to S3 and releases the compute, so you pay only for the training time.
  5. 5. Which is a common cause of an unexpectedly high SageMaker bill?

    Endpoints and notebook instances bill by the hour while they exist. Stop or delete anything you are not using.

Summary

  • Choose the highest level that works: ready-made AI services, then Bedrock foundation models, then SageMaker for your own models.
  • Rekognition, Textract, Comprehend, Translate, Transcribe and Polly turn a hard problem into an API call.
  • Bedrock offers foundation models behind one API, with Knowledge Bases (RAG), Agents and Guardrails.
  • SageMaker covers build, train and deploy: Studio and JumpStart, training jobs that write artifacts to S3, and real-time, serverless, asynchronous and batch deployments.
  • Real-time endpoints bill every hour, so shut down what you do not use.

Next: AWS IoT Core and the IoT Family