In the present day, we’re saying inline payload help for Amazon SageMaker AI Async Inference. Prospects can now ship inference payloads immediately within the request physique of the InvokeEndpointAsync API, eradicating the necessity to add enter information to Amazon Easy Storage Service (Amazon S3) earlier than every invocation.
For payloads as much as 128,000 bytes, this removes a whole community round-trip, simplifies client-side code, and reduces the operational floor space of asynchronous inference workloads.
On this put up, we clarify the motivation behind this function, stroll by means of the client expertise earlier than and after, and present you begin utilizing inline payloads at present.
Background: How async inference labored earlier than
You should use Amazon SageMaker AI Async Inference to queue inference requests and course of them asynchronously. It’s a great match for workloads with massive payloads, variable site visitors, or tolerance for seconds-to-minutes latency. It helps computerized scaling to zero, making it cost-efficient for bursty or batch-style workloads.
Till now, the workflow required two steps on each invocation:
- Add the enter payload to an Amazon S3 bucket.
- Invoke the endpoint, passing the S3 object URI as
InputLocation.
The endpoint processes the request asynchronously and writes the output to a configured S3 output location, which the shopper polls or receives through Amazon Easy Notification Service (Amazon SNS) notification.
This two-step sample works nicely for big payloads (pictures, audio, multi-MB paperwork). However for purchasers with small enter payloads (in KB) who want longer processing instances than real-time inference permits, the obligatory S3 dependency added pointless complexity.
What’s new: Inline payload through the Physique parameter
With at present’s launch, InvokeEndpointAsync accepts a brand new Physique parameter. When current, the payload is shipped inline within the API request itself, with no S3 add required.
Key particulars:
| Side | Particulars |
| New parameter | Physique, uncooked bytes, capped at 128,000 bytes. |
| Max inline dimension | 128,000 bytes (uncooked payload). |
| Mutual exclusivity | Physique and InputLocation are mutually unique. The API rejects requests that set each. |
| Output habits | Unchanged. Output is written to the S3 OutputLocation. |
| Endpoint compatibility | Designed to work with current async endpoints; no mannequin or container adjustments anticipated. |
| Error dealing with | Measurement and mutual-exclusivity violations return synchronous ValidationError responses. |
| Availability | Out there in 31 business AWS Areas (BOM, PDX, YUL, IAD, CMH, SFO, LHR, ICN, SYD, HKG, YYC, GRU, QRO, DUB, CDG, FRA, ZRH, ARN, ZAZ, NRT, KIX, SIN, CGK, MEL, KUL, BKK, HYD, TPE, CPT, MXP, TLV). |
Earlier than and after: The shopper expertise
The change is clearest in code. The 2 examples that comply with carry out the identical async invocation towards the identical endpoint. The primary makes use of the S3 add step that was required till now, and the second makes use of the inline Physique parameter that replaces it.
Earlier than: Add to S3 first, then invoke
This strategy requires:
- An S3 shopper and enter bucket provisioned.
- AWS Id and Entry Administration (IAM)
s3:PutObjectpermission on the caller. - A naming scheme (UUID or comparable) to keep away from key collisions.
- A cleanup technique for stale enter objects.
After: Ship the payload inline
No S3 shopper, no uuid, no enter bucket, no IAM grants on the enter path, no stale-object cleanup.
Buyer advantages
Sending the payload inline removes a community hop and a dependency from every request. That interprets into 5 concrete advantages:
- Decreased latency. One community round-trip and one S3 PUT eliminated per request. For fan-out workloads, this latency financial savings compounds meaningfully.
- Easier structure. Avoids the enter bucket provisioning, lifecycle insurance policies, cross-account entry patterns, and the caller’s IAM
s3:PutObjectpermission on the enter path. - Fewer error paths. The request is a single API name. It both enqueues or it doesn’t.
- Decrease price. Removes the S3 PUT cost for the enter add on each inline invocation.
- Instant validation suggestions. Measurement and mutual-exclusivity errors are returned synchronously.
When to make use of every strategy
Inline payloads are sometimes the less complicated alternative for small payloads, however InputLocation nonetheless has its place. Use the next desk to resolve which path suits a given workload:
| Situation | Beneficial strategy |
| Payload <= 128,000 bytes (JSON prompts, structured information) | Inline Physique. Easier. Avoids one community round-trip and S3 PUT prices. |
| Payload > 128,000 bytes (pictures, audio, massive paperwork) | InputLocation. Add to S3 first. |
| Combined workload with variable payload sizes | Department on dimension. Use Physique for small, InputLocation for big. |
| Must retain enter information in S3 for audit or replay | InputLocation. Retains inputs in your bucket. |
Getting began
See the instance code pocket book for a full walkthrough.
Earlier than you start, ensure you have:
- An current Amazon SageMaker AI Async Inference endpoint (confirm with
aws sagemaker describe-endpoint --endpoint-name my-async-endpoint). - The most recent AWS SDK for Python (Boto3) put in and configured with credentials.
- IAM permissions for
sagemaker:InvokeEndpointAsync. - An S3 output bucket configured on your async endpoint (for instance,
my-output-bucket).
Notice: Following this information makes use of billable AWS sources. SageMaker AI async inference endpoints incur prices for example hours, and S3 buckets incur prices for storage and requests. Comply with the cleanup steps after finishing the tutorial to keep away from ongoing prices.
Steps
Inline payload help is offered at present. To make use of it:
- Replace your AWS SDK. Set up or improve Boto3 to the newest model:
pip set up --upgrade boto3. - Confirm the set up:
pip present boto3. - Exchange your invocation code. In your software, substitute the S3 add +
InputLocationsample with a directPhysiqueparameter, as proven within the previous code instance. - Check your invocation by calling the
InvokeEndpointAsyncAPI with thePhysiqueparameter. - Confirm the response comprises an
OutputLocationdiscipline. - Ballot or monitor the S3
OutputLocationto substantiate your inference consequence was written efficiently.
No adjustments are wanted to your endpoint configuration, mannequin container, or output S3 setup.
Clear up
To keep away from ongoing prices, delete the sources used on this walkthrough:
- Delete the SageMaker AI endpoint if it was created for testing:
- Delete the output S3 bucket (if now not wanted). Warning: Deleting an S3 bucket completely removes the objects inside it. Confirm you might have backed up any inference outcomes you have to retain.
- Take away any IAM insurance policies created particularly for this tutorial.
Conclusion
Inline payload help for SageMaker AI Async Inference removes a typical friction level in asynchronous inference workflows: the obligatory S3 add for each request. For almost all of inference payloads that match inside 128,000 bytes, now you can make a single API name and let SageMaker AI deal with the remaining.
The function is designed to be backward-compatible. Present InputLocation workflows proceed unchanged. Each inline and S3 inputs are processed identically as soon as the request is accepted, and fashions obtain an identical requests no matter enter supply.
Get began at present by updating your AWS SDK and utilizing the Physique parameter on the SageMaker AI InvokeEndpointAsync API. To be taught extra about asynchronous inference, see the Amazon SageMaker AI Async Inference documentation.
Concerning the authors

