invoke_endpoint_async
¶
invoke_endpoint_async(
endpoint_name: EndpointName,
*,
config_overrides: Optional[SageMakerRuntimeClientConfig] = None,
content_type: Optional[Header] = None,
accept: Optional[Header] = None,
custom_attributes: Optional[CustomAttributesHeader] = None,
inference_id: Optional[InferenceId] = None,
input_location: Optional[InputLocationHeader] = None,
s3_output_path_extension: Optional[S3OutputPathExtensionHeader] = None,
filename: Optional[FilenameHeader] = None,
request_ttl_seconds: Optional[RequestTTLSecondsHeader] = None,
invocation_timeout_seconds: Optional[InvocationTimeoutSecondsHeader] = None,
body: Optional[AsyncBodyBlob] = None,
) -> InvokeEndpointAsyncOutput
After you deploy a model into production using Amazon SageMaker AI hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint in an asynchronous manner.
Inference requests sent to this API are enqueued for asynchronous processing. The processing of the inference request may or may not complete before you receive a response from this API. The response from this API will not contain the result of the inference request but contain information about where you can locate it.
Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.
Calls to InvokeEndpointAsync are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.
Parameters:
-
endpoint_name(EndpointName) –The name of the endpoint that you specified when you created the endpoint using the CreateEndpoint API.
-
content_type(Optional[Header], default:None) –The MIME type of the input data in the request body.
-
accept(Optional[Header], default:None) –The desired MIME type of the inference response from the model container.
-
custom_attributes(Optional[CustomAttributesHeader], default:None) –Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1).
The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with
Trace ID:in your post-processing function.This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.
-
inference_id(Optional[InferenceId], default:None) –The identifier for the inference request. Amazon SageMaker AI will generate an identifier for you if none is specified.
-
input_location(Optional[InputLocationHeader], default:None) –The Amazon S3 URI where the inference request payload is stored.
-
s3_output_path_extension(Optional[S3OutputPathExtensionHeader], default:None) –The path extension that is appended to the Amazon S3 output path where the inference response payload is stored.
-
filename(Optional[FilenameHeader], default:None) –The filename for the inference response payload stored in Amazon S3. If not specified, Amazon SageMaker AI generates a filename based on the inference ID.
-
request_ttl_seconds(Optional[RequestTTLSecondsHeader], default:None) –Maximum age in seconds a request can be in the queue before it is marked as expired. The default is 6 hours, or 21,600 seconds.
-
invocation_timeout_seconds(Optional[InvocationTimeoutSecondsHeader], default:None) –Maximum amount of time in seconds a request can be processed before it is marked as expired. The default is 15 minutes, or 900 seconds.
-
body(Optional[AsyncBodyBlob], default:None) –Provides inline input data for the inference request, in the format specified in the
ContentTyperequest header. Use this parameter to send the request payload directly in the API call instead of uploading it to Amazon S3 and referencing it withInputLocation. The inline payload can be up to 128,000 bytes.BodyandInputLocationare mutually exclusive. Provide exactly one of them.For information about the format of the request body, see Common Data Formats-Inference.
Raises:
-
InternalFailure–An internal failure occurred.
-
ServiceUnavailable–The service is unavailable. Try your call again.
-
ValidationError–Inspect your request and try again.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_sagemaker_runtime/_services/sage_maker_runtime.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | |