The official EAS SDKs are available in Java, Python, and Golang, and are the recommended way to invoke services in VPC direct connection scenarios. The SDKs encapsulate service discovery, load balancing, token signing, and retry on failure, so you can complete service invocation quickly.
Use cases
The typical use case for the official EAS SDKs is VPC direct connection. In this scenario, the SDK saves you from implementing service discovery and load balancing yourself.
For other invocation methods, such as through a Shared Gateway or a dedicated gateway, a standard HTTP client is usually sufficient, and the SDK is not required.
For guidance on selecting an invocation method, see Service invocation.
How it works
The SDK supports two endpoint types: gateway access and VPC direct connection. The two types differ in request routing but follow the same invocation process, which has the following three stages:
-
Initialize the client: Create a
PredictClientand set the endpoint, service name, and token. You can obtain the token from the service details page in the EAS console. Callinit()to complete initialization. -
Construct a request: Construct a request object, such as
StringRequest,TFRequest, orTorchRequest, based on the service's input and output formats. The request type must match the one the service expects. For services deployed with a processor, see Processor deployment for the request type corresponding to each processor. -
Invoke the service: Call the
predict()method to send the request and receive the response. The SDK automatically handles token signing, retry on failure (five times by default), and response deserialization, without any user intervention.
In VPC direct connection scenarios, the official SDK encapsulates the service discovery and load balancing logic. For details, see VPC direct connection - Call with the official SDK.
In addition to the synchronous inference calls described above, the SDK also provides a queue service invocation method:
-
Use a
QueueClientto push requests asynchronously to an input queue. The service consumes (dequeues) the requests and writes the results to an output queue. -
The client receives the results by subscribing to (watching) the output queue.
This method is suited for asynchronous inference and long-running tasks. For detailed instructions, see the examples in each language-specific SDK guide.
Invocation troubleshooting
If an SDK call fails, troubleshoot layer by layer in this order: client → network → server-side. The classification of common issues and the matching troubleshooting directions are as follows:
-
Authentication (401 / 403): Check whether the token is passed correctly, matches the target service, or was reset in the console.
-
Routing (404): Verify that the endpoint and service name match the values on the service details page in the EAS console. If you use a VPC direct connection, confirm that service discovery has fetched the instance list.
-
Connectivity (connection refused / timeout / DNS resolution failed): Verify that the client and server are in the same VPC, that security group rules allow the traffic, and that the endpoint domain is resolvable.
-
Server-side (5xx / empty response / invalid response format): Check the service logs to find the root cause of these issues.
For a complete list of service status codes, typical error messages, and recommended solutions, see Appendix: Service status codes and common errors.