

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 調用非同步端點
<a name="async-inference-invoke-endpoint"></a>

使用 `InvokeEndpointAsync` 從非同步端點上託管的模型中獲取推論。

**注意**  
如果您尚未這麼做，請將您的推論資料 (例如機器學習模型、範例資料) 上傳到 Amazon S3。

在請求中指定下列欄位：
+ 對於 `InputLocation`，指定推論資料的位置。
+ 對於 `EndpointName`，指定端點的名稱。
+ (選用) 對於 `InvocationTimeoutSeconds`，您可以設定請求的最大逾時。您可以將此值設定為每個請求上限 3600 秒 (一小時)。如果您未在請求中指定此欄位，請求逾時預設值是 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 區域 in your AWS 帳戶. 
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 呼叫進行回應。