AWS.SageMakerRuntime reference
InvokeEndpoint
Section titled “InvokeEndpoint”Source:
src/AWS/SageMakerRuntime/InvokeEndpoint.ts
Runtime binding for sagemaker:InvokeEndpoint — run real-time inference
against a deployed SageMaker endpoint with a model-native request body.
SageMaker Runtime is a pure pay-per-call data-plane API: the endpoint
itself is provisioned out of band (a deployed SageMaker model/endpoint —
costly to keep running). The binding takes one or more endpoint names and
grants the function sagemaker:InvokeEndpoint scoped to exactly those
endpoint ARNs. Pass the request/response bodies as raw bytes — the
container behind the endpoint owns the payload shape, no marshalling.
InvokeEndpoint: Invoking an Endpoint
Section titled “InvokeEndpoint: Invoking an Endpoint”// initconst invokeEndpoint = yield* AWS.SageMakerRuntime.InvokeEndpoint( "my-model-endpoint",);
// runtime — Body is the raw payload the container expectsconst result = yield* invokeEndpoint({ ContentType: "application/json", Accept: "application/json", Body: JSON.stringify({ instances: [[1, 2, 3, 4]] }),});const raw = new TextDecoder().decode(result.Body);InvokeEndpointAsync
Section titled “InvokeEndpointAsync”Source:
src/AWS/SageMakerRuntime/InvokeEndpointAsync.ts
Runtime binding for sagemaker:InvokeEndpointAsync — enqueue an
asynchronous inference request against a deployed SageMaker async endpoint.
The request payload is read from S3 (InputLocation) and the result is
written back to S3; the call returns immediately with an OutputLocation.
The binding takes one or more endpoint names and grants the function
sagemaker:InvokeEndpointAsync scoped to exactly those endpoint ARNs.
InvokeEndpointAsync: Invoking an Async Endpoint
Section titled “InvokeEndpointAsync: Invoking an Async Endpoint”// initconst invokeAsync = yield* AWS.SageMakerRuntime.InvokeEndpointAsync( "my-async-endpoint",);
// runtimeconst result = yield* invokeAsync({ ContentType: "application/json", InputLocation: "s3://my-bucket/input/request.json",});// result.OutputLocation — poll S3 for the written inference resultInvokeEndpointWithResponseStream
Section titled “InvokeEndpointWithResponseStream”Source:
src/AWS/SageMakerRuntime/InvokeEndpointWithResponseStream.ts
Runtime binding for sagemaker:InvokeEndpointWithResponseStream — the
streaming variant of InvokeEndpoint. The inference response arrives
incrementally as an event Stream of PayloadPart events carrying raw
model-specific bytes; the container behind the endpoint must support
inference streaming.
The binding takes one or more endpoint names and grants the function
sagemaker:InvokeEndpoint (the IAM action the streaming operation
authorizes against) scoped to exactly those endpoint ARNs.
InvokeEndpointWithResponseStream: Streaming an Endpoint Response
Section titled “InvokeEndpointWithResponseStream: Streaming an Endpoint Response”// initconst invokeStream = yield* AWS.SageMakerRuntime.InvokeEndpointWithResponseStream( "my-streaming-endpoint",);
// runtime — Body is the raw payload the container expectsconst result = yield* invokeStream({ ContentType: "application/json", Body: JSON.stringify({ inputs: "Say hello." }),});const events = yield* Stream.runCollect(result.Body);// each PayloadPart's Bytes is a model-specific chunk