How LiteLLM exposes SageMaker endpoints in OpenAI format
A team with models already running on SageMaker endpoints usually wants callers to reach them through one OpenAI-format API, with keys, budgets and logs enforced in one place. The LiteLLM proxy provides that layer. Each SageMaker endpoint is addressed with the sagemaker/<endpoint-name> route, so an application sends a standard chat completion request to the gateway and names the endpoint in the model field. The gateway then calls the endpoint with AWS credentials it holds, which means callers never see AWS keys and never need IAM access to SageMaker themselves. The credentials are typically supplied through the standard AWS credential chain and a region setting; confirm with your cloud team which identity the gateway will assume, which IAM actions that identity needs on the endpoint, and where the credentials are stored, since LiteLLM's guidance is to keep master keys and secrets in a secret manager.
Two behaviours need planning before callers depend on the route. First, SageMaker does not support streaming on this route, so LiteLLM fakes streaming by returning chunks of a completed response. Client applications that expect token-by-token output will still work, but the first token arrives only after the model has finished generating, which changes latency expectations and any timeout settings in front-end code. Test this with the real callers and their timeouts. Second, cost tracking is runtime-based. SageMaker bills for the instance time an endpoint runs, not per token, so LiteLLM's per-token price tables do not describe the spend. LiteLLM's custom pricing supports cost per second for runtime-billed deployments, and that rate needs to be set from your own instance pricing and the number of instances behind the endpoint. Ask your team to confirm the rate and to check that the resulting spend figures match the AWS bill before budgets are enforced on them.
What you need before connecting SageMaker to LiteLLM
Connecting a SageMaker endpoint to LiteLLM depends on four things working together: a gateway deployment with its state stores, a running endpoint with a known name, an AWS identity allowed to call it, and a network path from the gateway to AWS. Confirm each one before you write any model configuration, because failures at the gateway often trace back to one of these foundations.
Gateway database for virtual keys
Virtual keys, budgets and spend tracking need a PostgreSQL database. LiteLLM's production guide names PostgreSQL as the primary supported database, so plan it as a managed or highly available service rather than a local container. Confirm that the proxy can reach it, that backups cover it, and that the spend data it holds will be used later for cost tracking against SageMaker runtime charges.
Production guideRedis for multi-instance gateways
A single proxy instance can run without Redis, but once you run more than one, Redis holds shared rate limits, router state and cache. The production guide requires Redis 7.0 or newer for this setup. If you plan horizontal scaling from the start, provision Redis now so that SageMaker endpoint cooldowns and retries behave the same way on every replica.
Deployed endpoint and its exact name
The route uses the sagemaker/ prefix followed by the endpoint name, so the name must match the endpoint in the AWS account and region you will call. Confirm that the endpoint is in service, that the model container accepts the request format you plan to send, and record the endpoint name and account. A renamed or deleted endpoint produces failures that look like gateway errors.
AWS identity and invoke permissions
The gateway authenticates to AWS with an identity such as an IAM role on the cluster, an instance profile or access keys, depending on your environment. That identity needs permission to invoke the endpoint and nothing broader. Confirm the current IAM actions for runtime invocation against AWS documentation before writing the policy, and scope the resource to the specific endpoint ARN where your setup allows it.
SageMaker provider docsRegion and endpoint alignment
The AWS region in the gateway configuration must match the region where the endpoint runs. Mismatches return errors that can resemble missing endpoints or permission problems. Decide which region the endpoint lives in, keep it in configuration as code, and record it alongside the endpoint name so that a region change or a second region for failover is a deliberate edit.
Network path to the SageMaker runtime
The gateway must reach the SageMaker runtime API over a path your security team has approved. In a private VPC, this may mean an interface endpoint for the runtime service and routes that keep traffic off the public internet. Confirm egress rules, DNS resolution, proxy settings and any firewall allowlists from every gateway node, and test the path from the actual pod or host rather than from a workstation.
Configuring the sagemaker/ route step by step
This sequence takes a SageMaker endpoint that is already running and makes it callable through a self-hosted LiteLLM gateway, with credentials, region and model entry set up and a test request logged against a virtual key.
Confirm the endpoint is InService
Before touching the gateway, check in the SageMaker console or with the AWS CLI that the endpoint status is InService, and record its exact endpoint name, since the route depends on that string. Confirm the endpoint sits in the AWS account and region your gateway will call, and that the model inside it accepts the request format you plan to send. Done when you can describe the endpoint and see the name and status written down in your change record.
Provision AWS credentials for the gateway
Ask your cloud team to give the gateway an IAM role with permission to invoke that specific endpoint, and attach it to the compute that runs the LiteLLM proxy (for example, a Kubernetes service account or an instance profile). Prefer this over static access keys, because the role rotates credentials without a config change. Limit the policy to the endpoint's ARN where your setup allows it. Done when a test call from the gateway host, using the role, returns a successful invocation of the endpoint.
Set the AWS region for the route
Set the region the gateway uses for SageMaker calls to match the region where the endpoint runs. Supply it as an environment variable or as a parameter on the model entry, following the LiteLLM SageMaker documentation for the version you run. Confirm the variable name against that page rather than assuming it. Done when the proxy starts without region errors and the value in its environment matches the endpoint's region.
Add the sagemaker/ model entry to the proxy config
In the proxy configuration file, add a model entry whose litellm_params model value uses the sagemaker/ prefix followed by your endpoint name, and give it a public model name that callers will use. Keep the config free of credential values. Store the file in version control so changes are reviewed. Done when the proxy restarts cleanly and the model appears in the proxy's model list endpoint for an authorized key.
Move secrets out of the config file
Keep the LITELLM_MASTER_KEY and any database or provider secrets in your secret manager and inject them as environment variables at runtime, not as literals in the YAML. Where the gateway uses static AWS keys in an exceptional case, load them the same way. Confirm that the config file, container image and logs contain no secret values. Done when a search of the config repository and a sample of proxy startup logs shows no secret material.
Create a virtual key scoped to the model
Using the master key from your secret manager, create a virtual key that can call only the new public model name, and set a small budget for the test. The virtual key table in PostgreSQL is where spend will be recorded, so the database must be reachable and migrated. Done when the key is listed with the model restriction and budget you set.
Send a non-streaming test request
Send a completion request with the virtual key to the proxy, targeting the public model name, and ask for a non-streaming response. Check that the reply is a valid completion and that the request appears in the proxy logs. Then query the spend records in PostgreSQL to confirm a row exists for the key and model. Because the sagemaker/ route does not stream natively, keep streaming tests for a later step. Done when you have a successful completion and a matching spend record for the test key.
Why streaming through SageMaker behaves differently
SageMaker does not support streaming on the sagemaker/ route, so LiteLLM fakes streaming for callers that request it. Instead of passing tokens through as the model generates them, LiteLLM waits for the full response from the endpoint and then returns it to the client in chunks. The caller still receives an OpenAI-format stream, so client code that parses server-sent events keeps working, but the content arrives in blocks after the model has finished. Any caller that expects true token-by-token output needs to be checked against this behaviour before it goes live.
For user-facing chat clients, the effect is most visible in time to first token. With true streaming, the first words appear shortly after generation starts. With chunked delivery, the user sees nothing until the endpoint has produced the whole answer, then text appears in bursts. Long completions therefore feel slower even when total latency is the same. Timeouts need the same attention: client libraries, load balancers, ingress controllers and any proxy in front of LiteLLM may hold the connection open for a full generation, so the timeout values set for streaming traffic should be confirmed against the longest responses your teams expect. Ask the endpoint owner for typical output lengths before setting them.
Test this before rollout with a caller that depends on true streaming. Send a long prompt through the gateway with streaming enabled, record the time to first chunk and the total time, and compare both against the same model called directly. Confirm that the client renders partial output correctly and that it handles the final chunk and stop reason. If a product requires real token streaming, decide whether to use a different route for that model, serve it through a runtime that streams natively, or change the product expectation. Confirm current SageMaker and LiteLLM behaviour in the LiteLLM SageMaker documentation before you finalize the design.
How a request travels from caller to SageMaker endpoint
The request starts at a caller holding a LiteLLM virtual key. The LiteLLM proxy checks that key against its budget and model access rules, then signs the call with AWS credentials from the gateway's credential chain and sends it to the SageMaker runtime endpoint. The response comes back to the caller in OpenAI format, and spend is written to PostgreSQL. Check the trust boundary: everything before the AWS subgraph runs in your network, and the SageMaker endpoint and its runtime billing sit on the AWS side.
Request path from caller through the LiteLLM proxy to a SageMaker endpoint, with the trust boundary marked.
Mapping SageMaker endpoints, AWS identities and LiteLLM keys
This table maps each SageMaker endpoint to the LiteLLM model name, AWS identity, region, virtual key scope and custom pricing entry that the gateway needs. Read each row as one field to decide and one field your own configuration must confirm, and keep one row per endpoint so cost and access stay traceable.
| Field | What to set | What to confirm in your config |
|---|---|---|
| Model name | The LiteLLM model name that callers request, mapped to the sagemaker/ route with your endpoint name | Endpoint name matches the deployed SageMaker endpoint exactly, and the caller-facing name is unique in model_list |
| AWS identity | An IAM role or credential the proxy uses to invoke the endpoint, scoped to that endpoint's invoke permission | The proxy runs under a role, not a personal access key, and the policy allows only the endpoints listed in this map |
| Region | The AWS region where the endpoint is deployed, set alongside the model entry | Region matches the endpoint's region, since a mismatch fails at invocation and is easy to miss in testing |
| Virtual key scope | Restrict each virtual key to the model names it may call, with its own budget and rate limits | Keys for this endpoint do not grant access to other SageMaker models or hosted provider models |
| Custom pricing entry | A cost per second value for the endpoint's runtime, recorded against the model name | Per-second rate comes from your AWS billing for the instance type and is kept current when instance types change |
| Streaming behavior | Expect simulated streaming, since SageMaker does not stream on this route and LiteLLM returns chunks of the response | Client code tolerates chunked delivery and does not depend on true token-level streaming for this model |
| Ownership record | One row per endpoint listing owner, team key, role and pricing source | Each entry has a named owner who approves changes to the role, region or rate |
Pricing SageMaker runtime as cost per second
SageMaker bills for endpoint runtime, not for tokens, so the cost number LiteLLM needs is a rate per second that the deployment consumes while it is running. LiteLLM's custom pricing supports cost per second for runtime-billed deployments such as SageMaker, which is the setting to use for this route in place of the per-token input and output prices that hosted model APIs publish. Per-token pricing ties spend to how much text a request moves through the model. Runtime pricing ties spend to how long the instances stay up, whether or not any request arrives. The custom pricing documentation linked from this page describes how to express that rate for a deployment.
Spend on an endpoint therefore follows three things: the instance type, the number of instances in service, and how long each one runs. Idle time is the main surprise. An endpoint that serves little traffic still accrues charges every second it is in service, so a budget set on per-request assumptions will look healthy while the bill grows. Instance count changes the rate directly, and autoscaling changes it over time. Scale-out lifts the effective cost per second during peaks, and scale-in only helps if the endpoint is allowed to shrink to the level the traffic supports. Ask the platform team which instance types, minimum and maximum instance counts, and scaling policies apply to each endpoint before any cost figure goes into LiteLLM.
The per-second figure must come from the reader's own AWS bill or the published SageMaker rate for the exact instance type and region in use, and it should be confirmed against the billing line items for that endpoint. A rate copied from another account, region or instance family will produce budgets that look precise and are wrong. If instance counts vary, the team should decide whether to set a rate for the typical fleet size or to update the rate when scaling policy changes. Treat the output as an estimate of runtime cost, then reconcile it against the monthly invoice, because LiteLLM's numbers only match the bill when the inputs do.
Securing the SageMaker credential path
The SageMaker route adds an AWS identity to a gateway that already holds provider keys and team budgets, so the risk sits in three places: the AWS principal, the LiteLLM master key and the virtual keys that callers use. The cards below cover each control and the checks to run before the route serves shared traffic.
Scope the IAM policy to named endpoints
The principal LiteLLM uses should be allowed to invoke only the SageMaker endpoints it routes to, not every endpoint in the account. List each endpoint by its ARN in the policy and add a separate statement for any endpoint that must be called for a different team. Confirm with your AWS administrator which SageMaker invoke actions your endpoint type requires, since this depends on how the endpoint is deployed.
LiteLLM SageMaker docsPrefer role-based credentials
Run the proxy with an IAM role attached to its compute (for example, an instance profile or a pod identity) rather than static access keys stored in the configuration. Role credentials rotate without changes to LiteLLM, and they keep long-lived secrets out of config files and container images. Ask your platform team which role mechanism your cluster or host supports and confirm that the proxy picks up the role's credentials as expected in your environment.
Hold the master key in a secret manager
LITELLM_MASTER_KEY grants administrative control over keys, budgets and models, so it should never sit in a plain config file or a shared chat. LiteLLM's production guidance says the key must start with sk- and should be kept in a secret manager. Inject it at runtime, limit who can read it, and plan a rotation procedure that does not depend on one person.
LiteLLM production guideRestrict virtual keys to the SageMaker model
Create virtual keys that can call only the SageMaker model name they need, so a key issued for one application cannot reach the endpoint or other providers. Pair the restriction with per-key or per-team budgets, so a runaway client stops at a known limit. Test the restriction by calling a different model with the key and confirming the gateway rejects the request.
Virtual keys docsLimit network exposure of the proxy
Place the proxy behind an internal load balancer or an API gateway, and allow inbound traffic only from the networks that need it. The proxy calls SageMaker over the AWS network path, so confirm whether your VPC design needs an endpoint for the SageMaker runtime and whether outbound traffic must be restricted to that service. Document the path from caller to proxy to endpoint so reviewers can trace where prompts travel.
Audit every invocation
Record who called the SageMaker route, which virtual key was used, which endpoint answered and when. Combine LiteLLM request logs with AWS CloudTrail for control-plane activity and confirm with your AWS team which invocation events the account records by default and what retention applies. Check that logs are written to storage your security team controls and that prompt content is handled under your data policy.
Common SageMaker failures in LiteLLM and how to fix them
This table lists the failures teams most often hit when routing LiteLLM to SageMaker endpoints, with the likely cause and the fix for each. Work down the rows in order, since an endpoint that is not InService or a region mismatch will hide later symptoms such as denied calls or zero cost.
| Failure | Likely cause | Fix |
|---|---|---|
| Endpoint not found | The name after sagemaker/ does not match the SageMaker endpoint name exactly, or the endpoint sits in a different account or region. | Copy the endpoint name from the SageMaker console and confirm the account and region the credentials resolve to before editing the route. |
| Endpoint not InService | The endpoint is still creating, updating, failed, or was deleted, so invocations cannot succeed. | Check the endpoint status in SageMaker and wait for InService or redeploy. Confirm the status before debugging the gateway. |
| Missing or wrong AWS region | No region is set for the sagemaker/ route, so the call goes to the wrong region or fails to resolve the endpoint. | Set the AWS region explicitly in the model configuration to the region where the endpoint runs and verify it matches the endpoint ARN. |
| IAM denial on InvokeEndpoint | The credential LiteLLM uses lacks sagemaker:InvokeEndpoint permission on that endpoint, or an SCP or resource policy blocks it. | Grant InvokeEndpoint on the specific endpoint ARN to the role or user LiteLLM assumes, then test with the same credential chain outside LiteLLM. |
| Expected streaming does not arrive | SageMaker does not support streaming on this route, so LiteLLM returns the response in chunks instead of token by token. | Set client expectations accordingly, or use a different route if true token streaming is required. Confirm the behavior with a test request. |
| Cost shows zero or wrong | Custom pricing is not defined for the endpoint, so spend is not computed from endpoint runtime. | Add cost per second for the deployment in custom pricing, based on the rate in your AWS billing for the instance, and reconcile a test call against the bill. |
| Throttling from endpoint capacity | The endpoint instance count or instance type cannot absorb the concurrent requests LiteLLM forwards, so SageMaker returns throttling errors. | Review endpoint instance count and autoscaling policy in SageMaker, and set rate limits or retries at the gateway to match what the endpoint can serve. |
Questions buyers ask about SageMaker and LiteLLM
How much does it cost to connect SageMaker endpoints to LiteLLM?
The LiteLLM software is open source under the MIT license for code outside the enterprise/ directory, so the license itself carries no fee for that code. Your costs come from the SageMaker endpoint runtime you already pay AWS for, the infrastructure that runs the proxy, PostgreSQL and Redis if you run more than one proxy instance, and the labor to configure and test the route. Ask any partner for a fixed-scope quote that lists each of these components separately, and state which items are one-time (setup, testing) and which recur (hosting, endpoint runtime, support).
How long does a basic SageMaker connection take to verify?
A basic check is a single endpoint, one set of AWS credentials, a sagemaker/ route in the LiteLLM configuration and a test request through the OpenAI-format API. The duration depends on how quickly your team can grant the IAM permissions, confirm the endpoint name and region, and reach the proxy from the calling application. Because timelines vary with your approval cycles and environment, ask for the verification steps and the dependencies in writing before agreeing on a schedule.
What does the work need from our AWS and platform teams?
The work needs an IAM identity that LiteLLM can use to call the endpoint, with permission scoped to the specific SageMaker endpoints it should reach, and the AWS region where those endpoints run. Your platform team must provide a place to run the proxy, a secret manager for the credentials and the master key, and network paths from the proxy to the AWS API. Confirm the IAM policy and credential method with your AWS security team before any build starts, since the exact permissions depend on your endpoint configuration.
Can our in-house team set this up without a partner?
Yes, a team with AWS and Kubernetes or container experience can set up one endpoint without outside help, since the configuration is a route prefix, credentials and a region. The harder work usually sits around the route: virtual keys and budgets, consistent logging, credential rotation, high availability with PostgreSQL and Redis, and upgrades on a supported release line. Decide which of these your team will own after the first endpoint works, and use that list to compare an internal build against a fixed-scope partner engagement.
How does streaming work for SageMaker endpoints through LiteLLM?
SageMaker does not support streaming on this route, so LiteLLM fakes streaming by returning chunks of a complete response. Callers that expect token-by-token output will still receive the content in chunks, but the first token arrives only after the model has finished generating. Test this with your real prompts and client applications, and decide whether that latency is acceptable for interactive use before you commit to this route for chat-style workloads.
How does per-second runtime pricing affect the decision?
SageMaker endpoints bill for the time the instance is running, not for each token, so an idle endpoint still costs money. LiteLLM supports custom pricing with a cost per second for runtime-billed deployments, which lets spend reports and budgets reflect that model. Ask your team to confirm the per-second rate for your instance type, and set the custom price in the proxy configuration so that virtual key budgets track real endpoint cost rather than an assumed per-token figure.
When should we choose a dedicated route instead of sagemaker/?
Choose a dedicated provider route when your model server exposes an API that the LiteLLM route for that provider handles natively, such as streaming support or provider-specific parameters that the generic SageMaker route cannot pass through. Also consider a dedicated route if the endpoint serves models where accurate token-level cost tracking matters more than runtime cost. Check the LiteLLM provider documentation for your server type, compare streaming and parameter behavior in a test, and then pick the route that matches your application's needs.
When SageMaker endpoints fit a shared LiteLLM gateway
Routing SageMaker endpoints through LiteLLM makes sense when the models your teams need already run on AWS in endpoints your own team built and operates, and when you want those models behind the same keys, budgets, routing and logs as your other providers. The gateway becomes the single place where a team's access to a fine-tuned or custom-hosted model is granted, limited and recorded, instead of every application holding its own AWS credentials and calling the SageMaker runtime directly. That consolidation is the main reason to take this route. It is less compelling when only one application calls one endpoint, because the gateway then adds a component to run without adding much control.
The fit depends on what the endpoint is. A SageMaker endpoint hosts a model container that you deploy and pay for by runtime, so it suits models that are already in production on AWS, models with data residency needs that keep them in your account, and custom or fine-tuned models that no managed model service offers. If the model you want is available through Amazon Bedrock, the Bedrock route in LiteLLM is usually the better fit, because you do not manage the serving infrastructure. If the model runs on your own GPUs outside AWS, or you want a model server you can move between clouds, a self-hosted OpenAI-compatible server or the vLLM route is the more natural choice. Confirm with your AWS account team and your own architecture review which option matches the workload before you commit to one.
Plan for the cost and behaviour differences before teams depend on the route. Endpoint runtime is billed whether or not requests arrive, so an idle endpoint still costs money, and a gateway budget only controls who can spend, not the idle runtime itself. Streaming also differs: SageMaker does not support streaming on this route, so LiteLLM returns the response in chunks, and any application that expects true token-by-token streaming needs to be tested against that behaviour. Ask your team to confirm the endpoint's instance type, auto scaling settings and expected request pattern, and to record which keys are allowed to call each endpoint, so that cost and access reviews have a clear owner.
How DeployOpen works on this
DeployOpen plans and implements the LiteLLM gateway that fronts your SageMaker endpoints, inside your own AWS accounts and networks. Each engagement starts with a written scope that names the endpoints, credentials, routes and cost settings to be configured, so your security and platform teams review the same plan before any work begins.
How we scope
- Inventory every SageMaker endpoint to expose, with its name, region, instance type and the callers that will use it.
- Agree how AWS credentials reach the gateway, whether through an IAM role or a managed secret, and who approves that access.
- Define the per-second pricing inputs for each endpoint so spend reports match your AWS billing data.
- Confirm streaming expectations with application owners, since the sagemaker/ route returns simulated streaming chunks.
How we build
- Deploy the LiteLLM proxy in your infrastructure with PostgreSQL and, where more than one instance runs, Redis configured.
- Configure sagemaker/ model entries, region settings and custom per-second pricing, then test each route end to end.
- Set virtual keys, budgets and model restrictions per team, and test that calls outside those limits are refused.
- Run security testing of the gateway configuration, including credential handling, admin access and network exposure.
How we hand over
- Deliver the configuration as version-controlled files, with the endpoint list, route names and pricing settings documented.
- Provide runbooks for adding an endpoint, rotating AWS credentials and checking spend against endpoint runtime.
- Walk your platform and security teams through the build, the test results and the open items before handover.
- Record each decision, its owner and any setting that must be confirmed against your AWS environment.
How we support
- Support covers upgrades to supported LiteLLM releases and changes to endpoints, routes and pricing after handover.
- Ongoing support, upgrades and continuous testing are available as a retainer agreed in writing.
- Retesting after configuration changes can be included in the written scope or the retainer.
- Each change is reviewed against the agreed scope so your team can see what changed and why.

