Use the PAI-EAS Python SDK to send inference requests to a Blade service running on a universal processor.
Prerequisites
Before you begin, ensure that you have:
A Blade service deployed on PAI-EAS
The endpoint URL and service name for your deployment
Python 3 installed
Install the SDK
pip install -U eas-prediction --userCall a Blade service
The following example shows the complete request flow: initialize a client, build a BladeRequest with input tensors, send the request, and read the output.
#!/usr/bin/env python
from eas_prediction import PredictClient
from eas_prediction import BladeRequest
# Replace with your actual endpoint URL and service name
client = PredictClient('<endpoint-url>', '<service-name>')
client.init()
# Build the request — add each input tensor with its shape and data type
req = BladeRequest()
req.add_feed('input_data', 1, [1, 360, 128], BladeRequest.DT_FLOAT, [0.8] * 46080)
req.add_feed('input_length', 1, [1], BladeRequest.DT_INT32, [187])
req.add_feed('start_token', 1, [1], BladeRequest.DT_INT32, [104])
# Declare the output tensor to fetch
req.add_fetch('output', BladeRequest.DT_FLOAT)
# Send the request and read the response
resp = client.predict(req)
print(resp.get_tensor_shape('output'))Replace the following placeholders with your actual values:
| Placeholder | Description | Example |
|---|---|---|
<endpoint-url> | The endpoint URL of your PAI-EAS service | http://1828488879222746.cn-shanghai.pai-eas.aliyuncs.com |
<service-name> | The name of your deployed Blade service | nlp_model_example |
Note: If your PAI-EAS service requires token-based authentication, pass the token when initializing the client. For details, see the eas-python-sdk repository.
What's next
For the full SDK API reference and additional examples, see the eas-python-sdk repository.
该文章对您有帮助吗?