Amazon SageMaker AI
Deploy an open-weights or fine-tuned LLM on SageMaker AI hosting in your own AWS account, call it through SigV4-signed InvokeEndpoint (or a gateway), scale it down when idle, and delete the endpoint, endpoint config and model when finished. SageMaker was renamed Amazon SageMaker AI (2024-12-03); API names, CLI commands (aws sagemaker), IAM prefixes and URLs still say sagemaker.
Scope: real-time, asynchronous and serverless endpoints, inference components, JumpStart models, AWS LMI (Large Model Inference) containers wrapping vLLM, scale to zero, autoscaling, aws sagemaker and aws sagemaker-runtime discovery, teardown and cost checks.
Out of scope: managed model APIs (aws-bedrock), choosing a provider (cloud-llms, choosing-llm-hosting), gateway keys and routing (llm-gateway), vLLM engine flags (vllm), quantization (model-quantization), training and fine-tuning (fine-tuning-llms), GPU sizing (choosing-hardware).
Work through the steps in order. Load a reference only when a step names it.
Discover first
Read-only; variable names only, never values.
command -v aws && aws --version
env | cut -d= -f1 | grep -E '^(AWS_|HF_|LITELLM)' || echo "no matching env vars"
aws sts get-caller-identity --query '{Account:Account,Arn:Arn}' --output json
REGION="${AWS_REGION:-${AWS_DEFAULT_REGION:-us-east-1}}"
aws sagemaker list-endpoints --region "$REGION" \
--query 'Endpoints[].[EndpointName,EndpointStatus,CreationTime]' --output table
aws sagemaker list-endpoint-configs --region "$REGION" --query 'EndpointConfigs[].EndpointConfigName' --output text
aws sagemaker list-models --region "$REGION" --query 'Models[].ModelName' --output text
aws sagemaker list-inference-components --region "$REGION" --query 'InferenceComponents[].[InferenceComponentName,EndpointName,InferenceComponentStatus]' --output table
aws service-quotas list-service-quotas --service-code sagemaker --region "$REGION" \
--query "Quotas[?contains(QuotaName,'endpoint usage')].[QuotaName,Value]" --output text | head -40
Anything InService is billing right now. Unverified: the --query field names above come from API shapes; adjust if a command errors.
Decision flow
- Hosted model API is enough? Use
aws-bedrock; SageMaker is for models Bedrock does not host, fine-tunes, or full control of the serving stack.
- Steady or low-latency traffic? Real-time endpoint on a GPU instance (
references/deploy-llm.md).
- Idle gaps and cold starts acceptable, need scale to zero with sync calls? Real-time endpoint using inference components and
MinInstanceCount 0 (references/scaling-and-cost.md).
- Queued, long or large requests (up to 1 GB payload, up to 1 hour)? Asynchronous endpoint, can scale to zero (
references/scaling-and-cost.md).
- Serverless Inference? Not for LLMs: no GPUs, max 6 GB memory (
references/scaling-and-cost.md).
- Pick the model: JumpStart for catalog models, LMI container with
HF_MODEL_ID for Hugging Face or S3 weights (references/deploy-llm.md).
- Gateway or clients:
references/litellm-and-clients.md.
- Broken:
references/troubleshooting.md. Done: references/teardown.md.
Rules
- Ask before anything billable. State instance type and count, max instances, region and a stop time first. An endpoint bills per instance-hour until deleted.
- Secrets stay secret. Use IAM roles; pass
HF_TOKEN for gated models from a secret manager or 0600 file, never printed or committed. No static keys in code.
- Pin versions. Pin the LMI container tag (from the DLC release list, not
latest) and model revision (HF_REVISION).
- Quota and budget checks before deploy. GPU instance quotas are per instance type and Region and are often zero; read them first and set an AWS Budget.
- Least privilege. Separate the execution role (what the container can read) from the caller role (
sagemaker:InvokeEndpoint on one endpoint ARN).
- Always tear down. Deleting the endpoint stops instance charges but leaves the endpoint config and model; delete all three, plus inference components, autoscaling targets and alarms, then verify.
- Do not hardcode prices. Read https://aws.amazon.com/sagemaker/ai/pricing/ and use Cost Explorer.
Workflows
1. Account, role and quota
2. Deploy an LLM
3. Connect LiteLLM and clients
4. Scale
5. Monitor cost
6. Update
7. Tear down
8. Troubleshoot
Reference index
| File |
Load when |
references/setup-and-auth.md |
Roles, quotas, region, CLI discovery, invoking permissions |
references/deploy-llm.md |
JumpStart, LMI container settings, CLI and boto3 deploy flows, invocation |
references/scaling-and-cost.md |
Endpoint types, autoscaling, scale to zero, async, serverless limits, budgets |
references/litellm-and-clients.md |
LiteLLM sagemaker/ routes, calling with boto3 and curl, OpenAI-style payloads |
references/teardown.md |
Removing every billable resource and verifying |
references/troubleshooting.md |
Symptom to cause to fix |
Companion skills
cloud-llms: npx skills add ScaleDockHQ/llm-skills --skill cloud-llms (compare providers, hybrid setups)
llm-gateway: npx skills add ScaleDockHQ/llm-skills --skill llm-gateway (one endpoint, keys, budgets)
aws-bedrock: npx skills add ScaleDockHQ/llm-skills --skill aws-bedrock (hosted models on AWS)
vllm: npx skills add ScaleDockHQ/llm-skills --skill vllm (engine flags behind LMI)
choosing-llm-hosting: npx skills add ScaleDockHQ/llm-skills --skill choosing-llm-hosting
self-hosted-llms: npx skills add ScaleDockHQ/llm-skills --skill self-hosted-llms
model-quantization: npx skills add ScaleDockHQ/llm-skills --skill model-quantization
fine-tuning-llms: npx skills add ScaleDockHQ/llm-skills --skill fine-tuning-llms
llm-observability: npx skills add ScaleDockHQ/llm-skills --skill llm-observability
llm-evals: npx skills add ScaleDockHQ/llm-skills --skill llm-evals
1---2name: aws-sagemaker3description: Host your own LLM on Amazon SageMaker AI endpoints (real-time, async, serverless, inference components), with JumpStart and LMI/vLLM containers, scale to zero, SigV4 invocation, teardown and cost checks. Use for SageMaker, JumpStart, LMI container, djl-inference, create-endpoint, invoke-endpoint, inference component, MinInstanceCount 0, sagemaker/ LiteLLM, endpoint left running. For hosted API models use aws-bedrock; for provider comparison cloud-llms; for gateway design llm-gateway; for vLLM flags vllm.4license: MIT5compatibility: Needs bash, curl, jq and AWS CLI v2, network access to AWS, an AWS account, an execution role for SageMaker, and GPU instance quota in the chosen Region. Endpoints, inference components, async queues and autoscaling bill the account, so each needs the user's approval.6metadata:7 source: https://skillmd.com/skills/scaledockhq/aws-sagemaker8 author: ScaleDockHQ9 version: "0.1.0"10---1112# Amazon SageMaker AI1314Deploy an open-weights or fine-tuned LLM on SageMaker AI hosting in your own AWS account, call it through SigV4-signed InvokeEndpoint (or a gateway), scale it down when idle, and delete the endpoint, endpoint config and model when finished. SageMaker was renamed **Amazon SageMaker AI** (2024-12-03); API names, CLI commands (`aws sagemaker`), IAM prefixes and URLs still say `sagemaker`.1516**Scope:** real-time, asynchronous and serverless endpoints, inference components, JumpStart models, AWS LMI (Large Model Inference) containers wrapping vLLM, scale to zero, autoscaling, `aws sagemaker` and `aws sagemaker-runtime` discovery, teardown and cost checks.1718**Out of scope:** managed model APIs (`aws-bedrock`), choosing a provider (`cloud-llms`, `choosing-llm-hosting`), gateway keys and routing (`llm-gateway`), vLLM engine flags (`vllm`), quantization (`model-quantization`), training and fine-tuning (`fine-tuning-llms`), GPU sizing (`choosing-hardware`).1920Work through the steps in order. Load a reference only when a step names it.2122## Discover first2324Read-only; variable names only, never values.2526```bash27command -v aws && aws --version28env | cut -d= -f1 | grep -E '^(AWS_|HF_|LITELLM)' || echo "no matching env vars"29aws sts get-caller-identity --query '{Account:Account,Arn:Arn}' --output json30REGION="${AWS_REGION:-${AWS_DEFAULT_REGION:-us-east-1}}"31aws sagemaker list-endpoints --region "$REGION" \32 --query 'Endpoints[].[EndpointName,EndpointStatus,CreationTime]' --output table33aws sagemaker list-endpoint-configs --region "$REGION" --query 'EndpointConfigs[].EndpointConfigName' --output text34aws sagemaker list-models --region "$REGION" --query 'Models[].ModelName' --output text35aws sagemaker list-inference-components --region "$REGION" --query 'InferenceComponents[].[InferenceComponentName,EndpointName,InferenceComponentStatus]' --output table36aws service-quotas list-service-quotas --service-code sagemaker --region "$REGION" \37 --query "Quotas[?contains(QuotaName,'endpoint usage')].[QuotaName,Value]" --output text | head -4038```3940Anything `InService` is billing right now. Unverified: the `--query` field names above come from API shapes; adjust if a command errors.4142## Decision flow43441. **Hosted model API is enough?** Use `aws-bedrock`; SageMaker is for models Bedrock does not host, fine-tunes, or full control of the serving stack.452. **Steady or low-latency traffic?** Real-time endpoint on a GPU instance (`references/deploy-llm.md`).463. **Idle gaps and cold starts acceptable, need scale to zero with sync calls?** Real-time endpoint using **inference components** and `MinInstanceCount` 0 (`references/scaling-and-cost.md`).474. **Queued, long or large requests (up to 1 GB payload, up to 1 hour)?** Asynchronous endpoint, can scale to zero (`references/scaling-and-cost.md`).485. **Serverless Inference?** Not for LLMs: no GPUs, max 6 GB memory (`references/scaling-and-cost.md`).496. **Pick the model:** JumpStart for catalog models, LMI container with `HF_MODEL_ID` for Hugging Face or S3 weights (`references/deploy-llm.md`).507. **Gateway or clients:** `references/litellm-and-clients.md`.518. **Broken:** `references/troubleshooting.md`. **Done:** `references/teardown.md`.5253## Rules5455- **Ask before anything billable.** State instance type and count, max instances, region and a stop time first. An endpoint bills per instance-hour until deleted.56- **Secrets stay secret.** Use IAM roles; pass `HF_TOKEN` for gated models from a secret manager or `0600` file, never printed or committed. No static keys in code.57- **Pin versions.** Pin the LMI container tag (from the DLC release list, not `latest`) and model revision (`HF_REVISION`).58- **Quota and budget checks before deploy.** GPU instance quotas are per instance type and Region and are often zero; read them first and set an AWS Budget.59- **Least privilege.** Separate the execution role (what the container can read) from the caller role (`sagemaker:InvokeEndpoint` on one endpoint ARN).60- **Always tear down.** Deleting the endpoint stops instance charges but leaves the endpoint config and model; delete all three, plus inference components, autoscaling targets and alarms, then verify.61- **Do not hardcode prices.** Read https://aws.amazon.com/sagemaker/ai/pricing/ and use Cost Explorer.6263## Workflows6465### 1. Account, role and quota6667- [ ] Region chosen, `aws sts get-caller-identity` works, GPU instance quota for the target type is above zero (`references/setup-and-auth.md`).68- [ ] Execution role exists with SageMaker trust and S3 and ECR read; caller can invoke.6970### 2. Deploy an LLM7172- [ ] Choose JumpStart or LMI (`references/deploy-llm.md`); size the instance with `choosing-hardware`.73- [ ] After approval, create model, endpoint config and endpoint (or `ModelBuilder.deploy`); wait for `InService`.74- [ ] Smoke test with `aws sagemaker-runtime invoke-endpoint` and a chat payload.7576### 3. Connect LiteLLM and clients7778- [ ] Add `sagemaker_chat/<endpoint>` (messages payload) or `sagemaker/<endpoint>` (`references/litellm-and-clients.md`).79- [ ] Test through the gateway; the gateway role needs `sagemaker:InvokeEndpoint`.8081### 4. Scale8283- [ ] Enable autoscaling; for scale to zero use inference components and `MinInstanceCount` 0 with a step policy and alarm, or async endpoints (`references/scaling-and-cost.md`).84- [ ] Expect minutes of cold start; clients must retry.8586### 5. Monitor cost8788- [ ] AWS Budgets, CloudWatch utilization, tag resources, `list-endpoints` daily.8990### 6. Update9192- [ ] Create a new endpoint config and `update-endpoint`, or a second endpoint plus gateway alias switch; delete the old config afterwards.9394### 7. Tear down9596- [ ] `references/teardown.md`: endpoint, endpoint config, model, inference components, autoscaling, alarms; verify.9798### 8. Troubleshoot99100- [ ] CloudWatch endpoint logs and `describe-endpoint` `FailureReason`, then `references/troubleshooting.md`.101102## Reference index103104| File | Load when |105| ----------------------------------- | ------------------------------------------------------------------------------- |106| `references/setup-and-auth.md` | Roles, quotas, region, CLI discovery, invoking permissions |107| `references/deploy-llm.md` | JumpStart, LMI container settings, CLI and boto3 deploy flows, invocation |108| `references/scaling-and-cost.md` | Endpoint types, autoscaling, scale to zero, async, serverless limits, budgets |109| `references/litellm-and-clients.md` | LiteLLM `sagemaker/` routes, calling with boto3 and curl, OpenAI-style payloads |110| `references/teardown.md` | Removing every billable resource and verifying |111| `references/troubleshooting.md` | Symptom to cause to fix |112113## Companion skills114115- `cloud-llms`: `npx skills add ScaleDockHQ/llm-skills --skill cloud-llms` (compare providers, hybrid setups)116- `llm-gateway`: `npx skills add ScaleDockHQ/llm-skills --skill llm-gateway` (one endpoint, keys, budgets)117- `aws-bedrock`: `npx skills add ScaleDockHQ/llm-skills --skill aws-bedrock` (hosted models on AWS)118- `vllm`: `npx skills add ScaleDockHQ/llm-skills --skill vllm` (engine flags behind LMI)119- `choosing-llm-hosting`: `npx skills add ScaleDockHQ/llm-skills --skill choosing-llm-hosting`120- `self-hosted-llms`: `npx skills add ScaleDockHQ/llm-skills --skill self-hosted-llms`121- `model-quantization`: `npx skills add ScaleDockHQ/llm-skills --skill model-quantization`122- `fine-tuning-llms`: `npx skills add ScaleDockHQ/llm-skills --skill fine-tuning-llms`123- `llm-observability`: `npx skills add ScaleDockHQ/llm-skills --skill llm-observability`124- `llm-evals`: `npx skills add ScaleDockHQ/llm-skills --skill llm-evals`