Amazon SageMaker Inference Router Runtime

2026/11/16 - Amazon SageMaker Inference Router Runtime - 2 new api methods

Changes  Amazon SageMaker adds Synthetic Data Generation, Auto-labeling, Data Quality Evaluation, and Data Transformation capabilities, Cross-Region Inference Routing, KV Aware routing for realtime inference endpoints.

InvokeInferenceRouter (new) Link ¶

Sends a real-time inference request to an inference router. In the request, you name the routing target, and the router sends the request to one of the routing target's destinations. The response includes the destination that served the request and the reason that the router chose it.

The following limits apply:

  • The maximum request payload is 6 MB. A request with a larger body fails with HTTP status code 413.

  • Your model has up to 60 seconds for each attempt, the same limit as InvokeEndpoint. If your account has a higher model execution timeout for InvokeEndpoint, it doesn't apply through an inference router. For models that take longer, use InvokeInferenceRouterAsync.

If a destination returns an error that the router can retry, such as a throttling error, before your model produces a response, the router retries the request once on another destination. A request that times out on a destination isn't retried. Because a request can make two attempts, set your client read timeout to at least 170 seconds.

The caller needs permission to invoke the inference router and every destination of the routing target. For information about permissions, see Route requests across Regions with inference routers.

See also: AWS API Documentation

Request Syntax

client.invoke_inference_router(
    InferenceRouterName='string',
    RoutingTargetName='string',
    ContentType='string',
    Accept='string',
    InferenceId='string',
    PrefixAwareId='string',
    CustomAttributes='string',
    Body=b'bytes'|file
)
type InferenceRouterName:

string

param InferenceRouterName:

[REQUIRED]

The name of the inference router to invoke.

type RoutingTargetName:

string

param RoutingTargetName:

[REQUIRED]

The name of the routing target in the inference router. The routing target lists the destinations that can serve the request.

type ContentType:

string

param ContentType:

The MIME type of the input data in the request body. The router passes it to the destination.

type Accept:

string

param Accept:

The MIME type that you want for the inference response. The router passes it to the destination.

type InferenceId:

string

param InferenceId:

An identifier for the inference request. The router passes it to the destination.

type PrefixAwareId:

string

param PrefixAwareId:

An optional, stable identifier that serves as a routing hint for prefix-aware routing. The router passes it to the destination that serves the request. Within that destination, requests with the same prefix and the same identifier go to the same instance. If requests from different applications might have the same prompt prefix, set a different identifier for each application to differentiate their routing decisions.

Applies only to destination endpoints configured with a RoutingStrategy of PREFIX_AWARE.

type CustomAttributes:

string

param CustomAttributes:

Provides additional information about the inference request. The value is an opaque string that the router passes, unchanged, to the model container of the destination that serves the request. The value can contain up to 1,024 visible US-ASCII characters.

type Body:

bytes or seekable file-like object

param Body:

[REQUIRED]

The input data for the inference, in the format that your model expects. The body can't be empty.

rtype:

dict

returns:

Response Syntax

{
    'Body': b'bytes'|file,
    'ContentType': 'string',
    'InvokedRoutedResourceArn': 'string',
    'RoutingReason': 'string',
    'InvokedProductionVariant': 'string',
    'CustomAttributes': 'string'
}

Response Structure

  • (dict) --

    • Body (bytes or seekable file-like object) --

      The inference that the model returned.

    • ContentType (string) --

      The MIME type of the inference returned in the response body.

    • InvokedRoutedResourceArn (string) --

      The Amazon Resource Name (ARN) of the endpoint or inference component that served the request.

    • RoutingReason (string) --

      The reason that the router chose the destination that served the request. Possible values:

      • local-preferred – The destination is a healthy destination in the router's Region.

      • capacity-available – No destination in the router's Region could take the request, and two or more destinations in other Regions could.

      • only-healthy – No destination in the router's Region could take the request, and exactly one destination in another Region could.

      • failover – The router moved the request away from destinations in its Region because they were overloaded or returning errors. You also see this value when the router can't assess destination health, and when no destination is healthy and the router tries one anyway.

    • InvokedProductionVariant (string) --

      The production variant of the destination endpoint that served the request.

    • CustomAttributes (string) --

      Provides additional information in the response about the inference. This is the value that the model container of the destination returned, unchanged.

InvokeInferenceRouterAsync (new) Link ¶

Submits an asynchronous inference request to an inference router. Before you call this operation, upload the input data to Amazon S3 in the router's Amazon Web Services Region. The router returns as soon as it accepts the request, and sends the request to one of the destinations of the routing target. The destination reads the input from Amazon S3, and the inference response is written to the Amazon S3 output path that the routing target specifies.

If a destination doesn't start the request within the routing target's MaxTimeInBacklogSeconds, the router moves the request to another destination. After your model starts processing the request, the request doesn't move. If no destination can take the request before RequestTTLSeconds runs out, or every destination has been tried, the router writes a failure object to the FailureLocation and publishes a notification to the routing target's error topic, if one is configured.

For information about the permissions that the caller and each destination need, see Send asynchronous requests through an inference router.

See also: AWS API Documentation

Request Syntax

client.invoke_inference_router_async(
    InferenceRouterName='string',
    RoutingTargetName='string',
    ContentType='string',
    Accept='string',
    CustomAttributes='string',
    InferenceId='string',
    InputLocation='string',
    S3OutputPathExtension='string',
    Filename='string',
    RequestTTLSeconds=123,
    InvocationTimeoutSeconds=123
)
type InferenceRouterName:

string

param InferenceRouterName:

[REQUIRED]

The name of the inference router to invoke.

type RoutingTargetName:

string

param RoutingTargetName:

[REQUIRED]

The name of the routing target in the inference router. The routing target must be configured for asynchronous inference.

type ContentType:

string

param ContentType:

The MIME type of the input data in Amazon S3. The router passes it to the destination.

type Accept:

string

param Accept:

The MIME type that you want for the inference response. The router passes it to the destination.

type CustomAttributes:

string

param CustomAttributes:

Provides additional information about the inference request. The value is an opaque string that the router passes, unchanged, to the model container of the destination that serves the request. The value can contain up to 1,024 visible US-ASCII characters.

type InferenceId:

string

param InferenceId:

An identifier for the inference request. If you don't provide one, SageMaker AI generates one and returns it in the response.

type InputLocation:

string

param InputLocation:

[REQUIRED]

The Amazon S3 URI of the object that contains the input data for the inference. The bucket must be in the inference router's Amazon Web Services Region and owned by the router's account. The destination endpoint's execution role reads the object, and the destination's asynchronous inference limits apply to it.

type S3OutputPathExtension:

string

param S3OutputPathExtension:

The path extension that is appended to the routing target's Amazon S3 output path where the inference response is stored.

type Filename:

string

param Filename:

The file name of the inference response stored in Amazon S3. If you don't provide one, SageMaker AI generates one.

type RequestTTLSeconds:

integer

param RequestTTLSeconds:

The time to live of the request, in seconds, measured from when the router accepts it. If no destination starts the request in this time, the request fails. The default is 21,600 seconds (6 hours).

type InvocationTimeoutSeconds:

integer

param InvocationTimeoutSeconds:

The maximum time, in seconds, that a destination can spend processing the request before the request is marked as expired. The default is 900 seconds (15 minutes).

rtype:

dict

returns:

Response Syntax

{
    'InferenceId': 'string',
    'OutputLocation': 'string',
    'FailureLocation': 'string'
}

Response Structure

  • (dict) --

    • InferenceId (string) --

      The identifier for the inference request. This is the InferenceId that you provided, or the one that SageMaker AI generated.

    • OutputLocation (string) --

      The Amazon S3 URI where the inference response is written. The location doesn't change if the router moves the request to another destination.

    • FailureLocation (string) --

      The Amazon S3 URI where the failure details are written if the inference fails.