如何从 appengine 中的 NodeJS 应用程序 运行 访问 Google CloudML REST API

How to access Google CloudML REST API from NodeJS application running in appengine

我是 运行 我在 CloudML 中的预测 运行。我想从我的 NodeJS 应用程序调用 predict REST API,我想在 AppEngine 的 NodeJS 应用程序 运行 中显示预测结果。

我可以找到 documentation 来为 Python 申请。但是找不到 NodeJS。

我可以使用像 node-rest-client? If yes how can I pass the Google Application Default Credentials 这样的普通 rest 客户端吗?

是的,您可以使用普通的 node-rest-client,但是由于 Google 应用程序默认凭据的过程没有融入该客户端,您必须使用 https://github.com/googleapis/google-auth-library-nodejs 才能使用应用程序默认凭据。

或者您可以使用 https://github.com/googleapis/google-api-nodejs-client,它应该支持开箱即用的 ADC。您可以在此处找到 Cloud ML API:

https://github.com/googleapis/google-api-nodejs-client/blob/master/src/apis/ml/v1.ts

具体来说,您正在寻找 "predict" 方法。