Running Gemini Batch Predictions via Curl Request Raises Error Code 13 – INTERNAL

Diligently following the Get batch predictions for Gemini instructions, I attempted the following curl request against a BigQuery dataset shown below. I have attempted multiple models (gemini-1.5-flash-001, gemini-1.5-pro-001, gemini-1.0-pro-002) that all raise the same uninformative Error Code 13 - INTERNAL.

Am I following the correct specifications, especially the BigQuery input and output URI sources? Is the model input with its parameters correctly specified?

Run

Curl Request (ran inside GCP cloud terminal shell)

curl -X POST 
     -H "Authorization: Bearer $(gcloud auth print-access-token)" 
     -H "Content-Type: application/json; charset=utf-8" 
     -d @request.json 
     "https://us-central1-aiplatform.googleapis.com/v1/projects/XXXXXXXXX/locations/us-central1/batchPredictionJobs"

Request JSON (ran literally inside above call in place of @request.json)

{
  "name": "economic_goods_batch",
  "displayName": "economic_goods_batch",
  "model": "publishers/google/models/gemini-1.5-flash-001",
  "inputConfig": {
    "instancesFormat": "bigquery",
    "bigquerySource": {
      "inputUri": "bq://XXXXXXXXX.gemini_econ_goods_batch.sample"
    }
  },
  "outputConfig": {
    "predictionsFormat": "bigquery",
    "bigqueryDestination": {
      "outputUri": "bq://XXXXXXXXX.gemini_econ_goods_batch.sample"
    }
  }
}

BigQuery Table: Sample

Contains one JSON type column, Request, with first row. I attempted to run on full table containing 99 rows and sample table containing 1 row. Both attemptes raised the Error code 13.

{
  "contents": [
    {
      "parts": "Which of the following types of economic goods describes the activity of playing baseball: public good, private good, common resources, and/or club good?. Please answer with a description.",
      "role": "user"
    }
  ],
  "generation_config": {
    "maxOutputTokens": 1000,
    "top_k": 5
  },
  "system_instruction": {
    "parts": [
      {
        "text": "You are an economics trained assistant. Your response must be a JSON array containing JSON objects of two elements: good_type and description."
      }
    ]
  }
}

Result

curl 
  -X GET 
  -H "Authorization: Bearer $(gcloud auth print-access-token)" 
  -H "Content-Type: application/json" 
https://us-central1-aiplatform.googleapis.com/v1/projects/gen-lang-client-XXXXXXXXX/locations/us-central1/batchPredictionJobs
{
  "batchPredictionJobs": [
    {
      "name": "projects/????????????/locations/us-central1/batchPredictionJobs/????????????",
      "displayName": "economic_goods_batch",
      "model": "publishers/google/models/gemini-1.0-pro-002",
      "inputConfig": {
        "instancesFormat": "bigquery",
        "bigquerySource": {
          "inputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "outputConfig": {
        "predictionsFormat": "bigquery",
        "bigqueryDestination": {
          "outputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "state": "JOB_STATE_FAILED",
      "error": {
        "code": 13,
        "message": "INTERNAL"
      },
      "createTime": "2024-06-12T15:40:31.753722Z",
      "startTime": "2024-06-12T15:40:31.962421Z",
      "endTime": "2024-06-12T15:42:50.600106Z",
      "updateTime": "2024-06-12T15:42:50.600106Z",
      "modelVersionId": "1"
    },
    {
      "name": "projects/????????????/locations/us-central1/batchPredictionJobs/????????????",
      "displayName": "economic_goods_batch",
      "model": "publishers/google/models/gemini-1.5-flash-001",
      "inputConfig": {
        "instancesFormat": "bigquery",
        "bigquerySource": {
          "inputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.sample"
        }
      },
      "outputConfig": {
        "predictionsFormat": "bigquery",
        "bigqueryDestination": {
          "outputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.sample"
        }
      },
      "state": "JOB_STATE_FAILED",
      "error": {
        "code": 13,
        "message": "INTERNAL"
      },
      "createTime": "2024-06-11T20:07:10.340485Z",
      "startTime": "2024-06-11T20:07:10.522629Z",
      "endTime": "2024-06-11T20:08:59.225966Z",
      "updateTime": "2024-06-11T20:08:59.225966Z",
      "modelVersionId": "1"
    },
    {
      "name": "projects/????????????/locations/us-central1/batchPredictionJobs/????????????",
      "displayName": "economic_goods_batch",
      "model": "publishers/google/models/gemini-1.5-flash-001",
      "inputConfig": {
        "instancesFormat": "bigquery",
        "bigquerySource": {
          "inputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "outputConfig": {
        "predictionsFormat": "bigquery",
        "bigqueryDestination": {
          "outputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "state": "JOB_STATE_FAILED",
      "error": {
        "code": 13,
        "message": "INTERNAL"
      },
      "createTime": "2024-06-10T22:44:19.973904Z",
      "startTime": "2024-06-10T22:44:20.180562Z",
      "endTime": "2024-06-10T22:46:38.819981Z",
      "updateTime": "2024-06-10T22:46:38.819981Z",
      "modelVersionId": "1"
    },
    {
      "name": "projects/????????????/locations/us-central1/batchPredictionJobs/????????????",
      "displayName": "economic_goods_batch",
      "model": "publishers/google/models/gemini-1.5-pro-001",
      "inputConfig": {
        "instancesFormat": "bigquery",
        "bigquerySource": {
          "inputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_batch"
        }
      },
      "outputConfig": {
        "predictionsFormat": "bigquery",
        "bigqueryDestination": {
          "outputUri": "bq://gen-lang-client-XXXXXXXXX.gemini_econ_goods_batch.economic_goods_response"
        }
      },
      "state": "JOB_STATE_FAILED",
      "error": {
        "code": 13,
        "message": "INTERNAL"
      },
      "createTime": "2024-06-09T18:26:52.102913Z",
      "startTime": "2024-06-09T18:26:52.299451Z",
      "endTime": "2024-06-09T18:28:40.856695Z",
      "updateTime": "2024-06-09T18:28:40.856695Z",
      "modelVersionId": "1"
    }
  ]
}

GCP audit Logs shows strange syntax errors at datetimes that do not correspond to job request. Such logs are not immediately available after job request.


Before running above batch predictions attempt, I have tested a single call with the Gemini Python API against same models to successfully receive output.

import os
import google.generativeai as genai

genai.configure(api_key=os.environ["GEMINIAI_API_KEY"])

model = genai.GenerativeModel(
    model_name = model_name = "gemini-1.5-flash-001", # "gemini-1.5-pro-001", #"gemini-1.5-pro-latest",
    system_instruction = (
        "You are an economics trained assistant. "
        "Your response must be a JSON array containing a list of "
        "JSON objects of two elements: good_type and description."
    )
)

prompt = (
    "Which of the following types of economic goods describes "
    "the activity of playing baseball: public good, "
    "private good, common resources, and/or club good?. "
    "Please answer with a description."
)


response = model.generate_content(
    prompt,
    generation_config=genai.GenerationConfig(
        response_mime_type = "application/json",
        max_output_tokens = 1000,
        top_k = 5
    )
)

print(response.text)
[
   {
      "good_type":"club good",
      "description":"A club good is a good that is excludable but not rivalrous. Playing baseball can be considered a club good because it is possible to exclude people from playing (e.g., requiring membership in a league or payment for access to a field). However, the enjoyment of the game by one person does not diminish the enjoyment of others. It is possible to have multiple players on the field at the same time without decreasing the enjoyment of the game for anyone."
   },
   {
      "good_type":"common resource",
      "description":"A common resource is a good that is rivalrous but not excludable.  This means that it is possible for multiple people to use the resource, but the resource is limited. Playing baseball can be considered a common resource because it can be rivalrous depending on the situation. For example, if there is only one baseball field available, then the enjoyment of the game by one group of people may diminish the enjoyment of the game for another group of people. However, it may be difficult to exclude people from playing baseball, especially if the game is played in a public park."
   }
]

Do note, attempting model, gemini-1.0-pro-002, raised:

google.api_core.exceptions.NotFound: 404 models/gemini-1.0-pro-002 is not found for API version v1beta, or is not supported for GenerateContent. Call ListModels to see the list of available models and their supported methods.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật