Deploy & Get Predictions
Pick the right endpoint type, then call it from any app.
1 min read
| Option | How it works | Best for |
|---|---|---|
| Real-time endpoint | Always-on instances, low latency | Steady traffic, interactive apps |
| Serverless inference | Scales to zero, billed per request | Spiky or low traffic that can tolerate cold starts |
| Asynchronous inference | Queues requests, results go to S3 | Large payloads, long processing times |
| Batch transform | Runs over a whole dataset in S3, then stops | Nightly scoring of all customers |
Deploy the model we just trained to a real-time endpoint:
Python
from sagemaker.serializers import CSVSerializer
predictor = estimator.deploy(
initial_instance_count=1,
instance_type="ml.m5.large",
serializer=CSVSerializer(),
)
print(predictor.endpoint_name)Any app (Lambda, ECS, EC2) can then call the endpoint with plain boto3, no SageMaker SDK needed:
Try it
predict.py
import boto3
runtime = boto3.client("sagemaker-runtime")
# One customer's features, in the same order as training (without the label)
row = "34,12,2,0,79.5,1"
resp = runtime.invoke_endpoint(
EndpointName="xgboost-2026-11-18-10-08-41-123",
ContentType="text/csv",
Body=row,
)
probability = float(resp["Body"].read().decode())
print(f"Churn probability: {probability:.0%}")Watch out
Real-time endpoints bill every hour they exist, even with zero traffic. Delete experiments when you're done:
predictor.delete_endpoint(). That's the most common surprise bill in SageMaker AI.
Key takeaways
- Real-time for steady low latency, serverless for spiky traffic, async for big jobs, batch for datasets.
- Apps call endpoints with boto3's sagemaker-runtime invoke_endpoint.
- Delete idle real-time endpoints, because they bill hourly.
Check your understanding
Pick an answer to see the explanation.
1. You need to score 2 million customers once a night. Which option?