You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过@google-cloud/language SDK调用医疗版Natural Language API

结论

你无法通过现有的通用@google-cloud/language SDK直接调用Healthcare Natural Language API,二者是相互独立的Google Cloud服务,底层服务端点、请求结构、权限体系均不互通,仅给通用客户端加额外参数无法完成适配。

可选实现方案

  • 方案1(推荐):使用Google Cloud官方提供的@google-cloud/healthcare Node.js SDK,该SDK已完整封装healthcare.googleapis.com的所有接口能力,包括医疗领域NLP的实体分析、术语归一化、医学关系抽取等专属功能,无需手动处理签名、鉴权等底层逻辑。
    示例代码参考:
    const { HealthcareService } = require('@google-cloud/healthcare');
    const healthcareClient = new HealthcareService();
    
    async function analyzeMedicalEntities(text, projectId, location, datasetId, nlpStoreId) {
      const parent = `projects/${projectId}/locations/${location}/datasets/${datasetId}/fhirStores/${nlpStoreId}`;
      const request = {
        parent,
        resource: {
          documentContent: Buffer.from(text).toString('base64'),
          type: 'PLAIN_TEXT',
        },
      };
      const response = await healthcareClient.projects.locations.datasets.fhirStores.analyzeEntities(request);
      return response[0];
    }
    
  • 方案2:如果不想引入额外的专属SDK,可使用Google通用API客户端googleapis手动指定Healthcare NLP的服务路径发起请求,相比直接发送原始HTTP请求可省略手动处理鉴权签名的步骤。
  • 方案3:直接向healthcare.googleapis.com发送符合接口规范的原始HTTP请求,需要自行处理身份验证、请求签名、参数序列化等流程,维护成本较高,不推荐。

内容的提问来源于stack exchange,提问作者seawolf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 14:06:03