

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 调用异步端点
<a name="async-inference-invoke-endpoint"></a>

使用 `InvokeEndpointAsync`，从托管在异步端点上的模型获取推理。

**注意**  
如果您还没有上传推理数据（例如机器学习模型、示例数据），请将数据上传到 Amazon S3。

在您的请求中指定以下字段：
+ 对于 `InputLocation`，请指定推理数据的位置。
+ 对于 `EndpointName`，请指定端点的名称。
+ （可选）对于 `InvocationTimeoutSeconds`，您可以设置请求的最大超时时间。您可以分别为每个请求设置此值，最大为 3600 秒（1 小时）。如果您未在请求中指定此字段，则默认情况下，请求超时时间为 15 分钟。

```
# Create a low-level client representing Amazon SageMaker Runtime
sagemaker_runtime = boto3.client("sagemaker-runtime", region_name=<aws_region>)

# Specify the location of the input. Here, a single SVM sample
input_location = "s3://bucket-name/test_point_0.libsvm"

# The name of the endpoint. The name must be unique within an AWS Region in your AWS account. 
endpoint_name='<endpoint-name>'

# After you deploy a model into production using SageMaker AI hosting 
# services, your client applications use this API to get inferences 
# from the model hosted at the specified endpoint.
response = sagemaker_runtime.invoke_endpoint_async(
                            EndpointName=endpoint_name, 
                            InputLocation=input_location,
                            InvocationTimeoutSeconds=3600)
```

您会收到 JSON 字符串响应，其中包含请求 ID 和 Amazon S3 存储桶的名称，该存储桶用于在处理完成后存储对 API 调用的响应。