错误消息

了解如何解决 Agent Platform Vision 引发的一些错误。本主题讨论解决方法需要多个步骤且无法在错误消息中简单说明的错误。

如需了解有关错误处理的最佳实践,请参阅 Cloud API 文档

权限

应用默认凭据不可用

如果收到此消息:

The Application Default Credentials are not available. They are
available if running in Google Compute Engine. Otherwise, the
environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined
pointing to a file defining the credentials.
See https://developers.google.com/accounts/docs/application-default-credentials
for more information.

权限遭拒

如果收到此消息:

ERROR: (gcloud.auth.application-default.print-access-token) File /path/to/key.json
(pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!
{
  "error": {
    "code": 403,
    "message": "The request is missing a valid API key.",
    "status": "PERMISSION_DENIED"
  }
}

确认 GOOGLE_APPLICATION_CREDENTIALS 环境变量中存储的位置中包含有效的服务账号密钥 JSON 文件,并且该变量指向正确的位置。

如需诊断此错误,请尝试从您尝试调用 Gemini Enterprise Agent Platform Vision API 的文件夹中打开服务账号密钥文件。

cat $GOOGLE_APPLICATION_CREDENTIALS

Forbidden: 403 POST API has not been used or is disabled

如果收到此消息:

Forbidden: 403 POST Gemini Enterprise Agent Platform Vision API has not been used in
project # before or it is disabled.
Enable it by visitng [url] then retry.
If you enabled this API recently, wait a few minutes for the action to
propagate and retry.

  1. 访问错误消息中指定的链接,并启用 Agent Platform Vision API。 等待几分钟,然后重试。
  2. 验证您是否在 GOOGLE_APPLICATION_CREDENTIALS 环境变量中存储了有效的服务账号密钥 JSON 文件。如需诊断此错误,请尝试从您尝试调用 Gemini Enterprise Agent Platform Vision API 的文件夹中打开服务账号密钥文件。
    cat $GOOGLE_APPLICATION_CREDENTIALS
    

实参无效

API 版本不受支持

示例:当向不支持相应操作的 API 版本发出请求时。

message: "The requested operation is unsupported for the API version."

Bad Request

发出 API 请求,但请求字段存在一项或多项违规情况。 每项违规行为都会在 google.rpc.BadRequest 详细信息中以 field_violations 的形式捕获。

message: "Request contains an invalid argument."
details {
  [type.googleapis.com/google.rpc.BadRequest] {
    field_violations { field: "foo" description: "bar" }
  }
}

项目编号无效

当提供的项目编号无效时。项目编号示例:848757893952147483648。

message: "Invalid project number used: 848757893952147483648."
details {
    [type.googleapis.com/google.rpc.ErrorInfo] {
      reason: "INVALID_PROJECT_NUMBER"
      domain: "visionai.googleapis.com"
    }
}

资源格式无效

资源格式无效时。项目编号示例:1234;位置 ID 示例:us-central1。

message: "Invalid Resource Used: project/1234/location/us-central1. Valid format should be "
"projects/{project_number}/locations/{location_id}."
details {
    [type.googleapis.com/google.rpc.ErrorInfo] {
      reason: "INVALID_RESOURCE_FORMAT"
      domain: "visionai.googleapis.com"
    }
}

未能满足前提条件

缺少视频数据

对于某些 API(例如用于分区级注解的 CreateAnnotation),必须先将视频数据流式传输到素材资源,才能推断出素材资源的开始时间。否则,系统会触发以下错误。

message: "Asset doesn't have start time inferred yet. Should ingest asset and retry."
details {
    [type.googleapis.com/google.rpc.ErrorInfo] {
      reason: "FAILED_PRECONDITION"
      domain: "visionai.googleapis.com"
    }
}

配额和限制

已超出配额

如果收到此消息:

RESOURCE_EXHAUSTED: Quota exceeded.

您已达到每分钟或每日配额的上限。查看使用 Agent Platform Vision 的配额和限制

您可以通过 Google Cloud 控制台申请增加配额。