SDK for PHP V3

Client: Aws\SageMakerInferenceRouterRuntime\SageMakerInferenceRouterRuntimeClient
Service ID: sagemaker-inference-router-runtime
Version: 2026-01-01

This page describes the parameters and results for the operations of the Amazon SageMaker Inference Router Runtime (2026-01-01), and shows how to use the Aws\SageMakerInferenceRouterRuntime\SageMakerInferenceRouterRuntimeClient object to call the described operations. This documentation is specific to the 2026-01-01 API version of the service.

Operation Summary

Each of the following operations can be created from a client using $client->getCommand('CommandName'), where "CommandName" is the name of one of the following operations. Note: a command is a value that encapsulates an operation and the parameters used to create an HTTP request.

You can also create and send a command immediately using the magic methods available on a client object: $client->commandName(/* parameters */). You can send the command asynchronously (returning a promise) by appending the word "Async" to the operation name: $client->commandNameAsync(/* parameters */).

InvokeInferenceRouter ( array $params = [] )
Sends a real-time inference request to an inference router.
InvokeInferenceRouterAsync ( array $params = [] )
Submits an asynchronous inference request to an inference router.

Operations

InvokeInferenceRouter

$result = $client->invokeInferenceRouter([/* ... */]);
$promise = $client->invokeInferenceRouterAsync([/* ... */]);

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.

Parameter Syntax

$result = $client->invokeInferenceRouter([
    'Accept' => '<string>',
    'Body' => <string || resource || Psr\Http\Message\StreamInterface>, // REQUIRED
    'ContentType' => '<string>',
    'CustomAttributes' => '<string>',
    'InferenceId' => '<string>',
    'InferenceRouterName' => '<string>', // REQUIRED
    'PrefixAwareId' => '<string>',
    'RoutingTargetName' => '<string>', // REQUIRED
]);

Parameter Details

Members
Accept
Type: string

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

Body
Required: Yes
Type: blob (string|resource|Psr\Http\Message\StreamInterface)

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

ContentType
Type: string

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

CustomAttributes
Type: string

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.

InferenceId
Type: string

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

InferenceRouterName
Required: Yes
Type: string

The name of the inference router to invoke.

PrefixAwareId
Type: string

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.

RoutingTargetName
Required: Yes
Type: string

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

Result Syntax

[
    'Body' => <string || resource || Psr\Http\Message\StreamInterface>,
    'ContentType' => '<string>',
    'CustomAttributes' => '<string>',
    'InvokedProductionVariant' => '<string>',
    'InvokedRoutedResourceArn' => '<string>',
    'RoutingReason' => '<string>',
]

Result Details

Members
Body
Type: blob (string|resource|Psr\Http\Message\StreamInterface)

The inference that the model returned.

ContentType
Type: string

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

CustomAttributes
Type: string

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

InvokedProductionVariant
Type: string

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

InvokedRoutedResourceArn
Type: string

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

RoutingReason
Type: 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.

Errors

ValidationException:

The request isn't valid. Check the inference router name, the routing target name, and the request parameters, and then try again.

AccessDeniedException:

You don't have permission to perform this action. Check that the caller is allowed to invoke the inference router and every destination of the routing target.

ServiceUnavailableException:

The service is temporarily unavailable. For example, no destination of the routing target could serve the request, or a destination didn't respond. Retry the request with exponential backoff. The Amazon Web Services SDKs and the Amazon Web Services CLI do this by default.

ModelError:

The model in the destination that served the request returned an error. Check OriginalStatusCode, OriginalMessage, and the destination's logs in Amazon CloudWatch.

ThrottlingException:

The request was denied because you exceeded the request rate for the inference router, or because a destination throttled the request. Retry the request with exponential backoff.

RequestTimeoutException:

The inference router didn't receive the complete request within 300 seconds of accepting it, for example because of a very slow upload. Retry the request.

InternalDependencyException:

The request failed because of an error in an internal dependency. Retry the request with exponential backoff.

InternalFailure:

An internal error occurred. Retry the request with exponential backoff. The Amazon Web Services SDKs and the Amazon Web Services CLI do this by default.

ModelNotReadyException:

The destination isn't ready to serve the model, for example because an inference component has no copies. Retry the request later.

Examples

Example 1: Invoke an inference router

The following example sends a JSON request to the my-target routing target of the my-router inference router. The response shows that a destination in the router's Region served the request.

$result = $client->invokeInferenceRouter([
    'Body' => <BLOB>,
    'ContentType' => 'application/json',
    'InferenceRouterName' => 'my-router',
    'RoutingTargetName' => 'my-target',
]);

Result syntax:

[
    'ContentType' => 'application/json',
    'RoutingReason' => 'local-preferred',
]

InvokeInferenceRouterAsync

$result = $client->invokeInferenceRouterAsync([/* ... */]);
$promise = $client->invokeInferenceRouterAsyncAsync([/* ... */]);

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.

Parameter Syntax

$result = $client->invokeInferenceRouterAsync([
    'Accept' => '<string>',
    'ContentType' => '<string>',
    'CustomAttributes' => '<string>',
    'Filename' => '<string>',
    'InferenceId' => '<string>',
    'InferenceRouterName' => '<string>', // REQUIRED
    'InputLocation' => '<string>', // REQUIRED
    'InvocationTimeoutSeconds' => <integer>,
    'RequestTTLSeconds' => <integer>,
    'RoutingTargetName' => '<string>', // REQUIRED
    'S3OutputPathExtension' => '<string>',
]);

Parameter Details

Members
Accept
Type: string

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

ContentType
Type: string

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

CustomAttributes
Type: string

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.

Filename
Type: string

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

InferenceId
Type: string

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

InferenceRouterName
Required: Yes
Type: string

The name of the inference router to invoke.

InputLocation
Required: Yes
Type: string

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.

InvocationTimeoutSeconds
Type: int

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).

RequestTTLSeconds
Type: int

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).

RoutingTargetName
Required: Yes
Type: string

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

S3OutputPathExtension
Type: string

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

Result Syntax

[
    'FailureLocation' => '<string>',
    'InferenceId' => '<string>',
    'OutputLocation' => '<string>',
]

Result Details

Members
FailureLocation
Type: string

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

InferenceId
Type: string

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

OutputLocation
Type: 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.

Errors

ValidationException:

The request isn't valid. Check the inference router name, the routing target name, and the request parameters, and then try again.

AccessDeniedException:

You don't have permission to perform this action. Check that the caller is allowed to invoke the inference router and every destination of the routing target.

ServiceUnavailableException:

The service is temporarily unavailable. For example, no destination of the routing target could serve the request, or a destination didn't respond. Retry the request with exponential backoff. The Amazon Web Services SDKs and the Amazon Web Services CLI do this by default.

ThrottlingException:

The request was denied because you exceeded the request rate for the inference router, or because a destination throttled the request. Retry the request with exponential backoff.

RequestTimeoutException:

The inference router didn't receive the complete request within 300 seconds of accepting it, for example because of a very slow upload. Retry the request.

InternalFailure:

An internal error occurred. Retry the request with exponential backoff. The Amazon Web Services SDKs and the Amazon Web Services CLI do this by default.

Shapes

AccessDeniedException

Description

You don't have permission to perform this action. Check that the caller is allowed to invoke the inference router and every destination of the routing target.

Members
Message
Type: string

A message that describes the error.

InternalDependencyException

Description

The request failed because of an error in an internal dependency. Retry the request with exponential backoff.

Members
Message
Type: string

A message that describes the error.

InternalFailure

Description

An internal error occurred. Retry the request with exponential backoff. The Amazon Web Services SDKs and the Amazon Web Services CLI do this by default.

Members
Message
Type: string

A message that describes the error.

ModelError

Description

The model in the destination that served the request returned an error. Check OriginalStatusCode, OriginalMessage, and the destination's logs in Amazon CloudWatch.

Members
LogStreamArn
Type: string

The Amazon Resource Name (ARN) of the Amazon CloudWatch log stream for the destination that served the request.

Message
Type: string

A message that describes the error.

OriginalMessage
Type: string

The error message that the model container returned.

OriginalStatusCode
Type: int

The HTTP status code that the model container returned.

ModelNotReadyException

Description

The destination isn't ready to serve the model, for example because an inference component has no copies. Retry the request later.

Members
Message
Type: string

A message that describes the error.

RequestTimeoutException

Description

The inference router didn't receive the complete request within 300 seconds of accepting it, for example because of a very slow upload. Retry the request.

Members
Message
Type: string

A message that describes the error.

ServiceUnavailableException

Description

The service is temporarily unavailable. For example, no destination of the routing target could serve the request, or a destination didn't respond. Retry the request with exponential backoff. The Amazon Web Services SDKs and the Amazon Web Services CLI do this by default.

Members
Message
Type: string

A message that describes the error.

ThrottlingException

Description

The request was denied because you exceeded the request rate for the inference router, or because a destination throttled the request. Retry the request with exponential backoff.

Members
Message
Type: string

A message that describes the error.

ValidationException

Description

The request isn't valid. Check the inference router name, the routing target name, and the request parameters, and then try again.

Members
Message
Type: string

A message that describes the error.