MaaS_Ge batch processing
google文档地址:https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/batch-prediction-from-cloud-storage?hl=zh-cn
一、上传文件
说明:文件最大支持100条请求数据,且文件最大不超过50MB,文件固定保存7天
批处理文件(jsonl格式)
batch_requests_for_multimodal_input_2.jsonl
文件内容示例
{"request":{"contents": [{"role": "user", "parts": [{"text": "List objects in this image."}, {"file_data": {"file_uri": "gs://cloud-samples-data/generative-ai/image/office-desk.jpeg", "mime_type": "image/jpeg"}}]}],"generationConfig":{"temperature": 0.4}}}
{"request":{"contents": [{"role": "user", "parts": [{"text": "List objects in this image."}, {"file_data": {"file_uri": "gs://cloud-samples-data/generative-ai/image/gardening-tools.jpeg", "mime_type": "image/jpeg"}}]}],"generationConfig":{"temperature": 0.4}}}
入参:
| 参数名 |
类型 |
是否必填 |
描述 |
| name |
string |
是 |
文件名 |
| uploadType |
string |
是 |
固定值media |
curl
```plain text
curl --location --request POST 'https://genaiapi.cloudsway.net/v1/ai/batch/gemini/{ENDPOINT}/files?uploadType=media&name=ImageToImage.jsonl' \
--header 'Authorization: Bearer {KEY}' \
--header 'Content-Type: application/octet-stream' \
--data-binary '@C:\Users\Desktop\batch\gemini\ImageToImage.jsonl'
### 出参
```json
{
"kind": "storage#object",
"id": "1779785513731222",
"name": "ImageToImage.jsonl",
"generation": "1779785513731222",
"metageneration": "1",
"contentType": "application/octet-stream",
"storageClass": "STANDARD",
"size": "510",
"md5Hash": "pM5qF/A+Eetto7iq5PZMsA==",
"crc32c": "unFIEg==",
"etag": "CJaJytrJ1pQDEAE=",
"timeCreated": "2026-05-26T08:51:53.742Z",
"updated": "2026-05-26T08:51:53.742Z",
"timeStorageClassUpdated": "2026-05-26T08:51:53.742Z",
"timeFinalized": "2026-05-26T08:51:53.742Z"
}
二、创建批处理任务
入参:
| 参数名 |
层级 |
类型 |
是否必填 |
描述 |
| displayName |
1 |
string |
是 |
任务名称 |
| inputConfig |
1 |
object |
是 |
|
| instancesFormat |
2 |
string |
是 |
固定值jsonl |
| gcsSource |
2 |
object |
是 |
|
| uris |
3 |
string |
是 |
上传文件的name值(第一步出参的name值) |
| outputConfig |
1 |
object |
是 |
|
| predictionsFormat |
2
|
string |
是 |
固定值jsonl |
curl
curl --location --request POST 'https://genaiapi.cloudsway.net/v1/ai/batch/gemini/{ENDPOINT}/batchPredictionJobs' \
--header 'Authorization: Bearer {KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{
"displayName": "my-cloud-storage-batch-inference-job",
"inputConfig": {
"instancesFormat": "jsonl",
"gcsSource": {
"uris": "{name}"
}
},
"outputConfig": {
"predictionsFormat": "jsonl"
}
}'
出参
{
"name": "903523130369114112",
"displayName": "my-cloud-storage-batch-inference-job",
"model": "MaaS_Ge_3.1_flash_image_preview_20260226",
"inputConfig": {
"instancesFormat": "jsonl",
"gcsSource": {
"uris": [
"ImageToImage.jsonl"
]
}
},
"outputConfig": {
"predictionsFormat": "jsonl",
"gcsDestination": {
"outputUriPrefix": "response"
}
},
"state": "JOB_STATE_PENDING",
"createTime": "2026-05-28T08:39:00.803441Z",
"updateTime": "2026-05-28T08:39:00.803441Z",
"modelVersionId": "1"
}
三、批处理状态
入参:
| 参数名 |
类型 |
是否必填 |
描述 |
| name |
string |
是 |
第二步出参的name值 |
curl
curl --location --request GET 'https://genaiapi.cloudsway.net/v1/ai/batch/gemini/{ENDPOINT}/batchPredictionJobs/{name}' \
--header 'Authorization: Bearer {KEY}'
出参
{
"name": "4787616125208756224",
"displayName": "my-cloud-storage-batch-inference-job",
"model": "MaaS_Ge_3_pro_image_preview_20251118_batch",
"inputConfig": {
"instancesFormat": "jsonl",
"gcsSource": {
"uris": [
"MaaS_Gemini_batch_1780628300511.jsonl"
]
}
},
"outputConfig": {
"predictionsFormat": "jsonl",
"gcsDestination": {
"outputUriPrefix": "response"
}
},
"outputInfo": {
"gcsOutputDirectory": "https://genaiapi.cloudsway.net/v1/ai/batch/gemini/{ENDPOINT}/batchPredictionJobs/4787616125208756224/content"
},
"state": "JOB_STATE_SUCCEEDED",
"error": null,
"completionStats": {
"successfulCount": "3",
"failedCount": null
},
"createTime": "2026-06-05T02:58:27.175092Z",
"startTime": "2026-06-05T02:59:01.122705Z",
"endTime": "2026-06-05T03:01:26.124246Z",
"updateTime": "2026-06-05T03:01:26.124246Z",
"modelVersionId": "1"
}
四、获取批处理结果
说明:返回结果固定保存7天
入参:
| 参数名 |
类型 |
是否必填 |
描述 |
| alt |
string |
否 |
当传json时,返回结果的元数据信息,当传media时,返回的是执行结果数据。默认为json |
| name |
string |
是 |
第二步出参的name值 |
curl
curl --location --request GET 'https://genaiapi.cloudsway.net/v1/ai/batch/gemini/{ENDPOINT}/batchPredictionJobs/{name}/content?alt=media' \
--header 'Authorization: Bearer {KEY}'
{"request":{"contents":[{"role":"user","parts":[{"file_data":null,"text":"List objects in this image."},{"file_data":{"file_uri":"gs://cloud-samples-data/generative-ai/image/office-desk.jpeg","mime_type":"image/jpeg"},"text":null}]}],"generationConfig":{"temperature":0.4}},"response":{"modelVersion":"MaaS_Ge_2.5_flash_20250617_batch","candidates":[{"content":{"role":"model","parts":[{"text":"Here are the objects visible in the image:\n\n* Globe\n* Eiffel Tower figurine\n* Airplane model\n* Tablet (with a blank white screen)\n* Miniature shopping cart\n* Red gift box (inside the shopping cart)\n* Coffee cup\n* Saucer\n* Coffee (in the cup)\n* Keyboard\n* Computer mouse\n* Passport\n* Sunglasses\n* One-dollar bill\n* Notebook / Notepad\n* Pen"}]},"score":-75.72122192382813,"avgLogprobs":-0.7011224252206308,"finishReason":"STOP"}],"createTime":"2026-01-29T02:15:37.871417Z","usageMetadata":{"candidatesTokenCount":108,"totalTokenCount":2163,"trafficType":"ON_DEMAND","billablePromptUsage":{"imageCount":1,"textCount":23},"promptTokensDetails":[{"modality":"TEXT","tokenCount":6},{"modality":"IMAGE","tokenCount":1806}],"thoughtsTokenCount":243,"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":108}],"promptTokenCount":1812},"responseId":"ycJ6afmXNYfWitUPtNOwuQE"},"processed_time":"2026-01-29T02:15:47.048543+00:00","status":""}
{"request":{"contents":[{"role":"user","parts":[{"file_data":null,"text":"List objects in this image."},{"file_data":{"file_uri":"gs://cloud-samples-data/generative-ai/image/gardening-tools.jpeg","mime_type":"image/jpeg"},"text":null}]}],"generationConfig":{"temperature":0.4}},"response":{"modelVersion":"MaaS_Ge_2.5_flash_20250617_batch","candidates":[{"content":{"role":"model","parts":[{"text":"Here are the objects visible in the image:\n\n1. **Watering can:** A large green plastic watering can with a white sprinkler head (rose).\n2. **Potted plant:** A small green plant growing in a terracotta pot.\n3. **Terracotta pots:** Two empty terracotta pots, stacked one on top of the other.\n4. **Hand trowel:** A small green gardening shovel with a black handle.\n5. **Hand hoe/cultivator:** A small green gardening tool with a hoe on one side and a three-pronged cultivator on the other, with a black handle.\n6. **Gardening gloves:** A pair of striped green, yellow, and white fabric gloves.\n7. **Grass:** The green lawn serving as the background surface."}]},"score":-168.0503692626953,"avgLogprobs":-1.0002998170398532,"finishReason":"STOP"}],"createTime":"2026-01-29T02:15:30.858407Z","usageMetadata":{"candidatesTokenCount":168,"totalTokenCount":2832,"trafficType":"ON_DEMAND","billablePromptUsage":{"imageCount":1,"textCount":23},"promptTokensDetails":[{"modality":"TEXT","tokenCount":6},{"modality":"IMAGE","tokenCount":1806}],"thoughtsTokenCount":852,"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":168}],"promptTokenCount":1812},"responseId":"wsJ6aaeyNIXVitUP5ruJiAo"},"processed_time":"2026-01-29T02:15:39.343388+00:00","status":""}
出参(alt为json)
{
"kind": "storage#object",
"id": "1780628480806264",
"generation": "1780628480806264",
"metageneration": "1",
"contentType": "application/octet-stream",
"storageClass": "STANDARD",
"size": "13306514",
"crc32c": "40/N2Q==",
"componentCount": 1,
"etag": "CPiazYCO75QDEAE=",
"timeCreated": "2026-06-05T03:01:20.809Z",
"updated": "2026-06-05T03:01:20.809Z",
"timeStorageClassUpdated": "2026-06-05T03:01:20.809Z",
"timeFinalized": "2026-06-05T03:01:20.809Z"
}