MaaS_Ge_X_image系列调用示例
请求方法
POST
请求路径
-
原生协议请求:https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/generateContent
-
OpenAI协议请求:https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/chat/completions
MaaS_Ge_3_pro_image_preview_20251120
接口及请求参数
MaaS_Ge_3_pro_image_preview_20251120 新增参数imageSize(与aspectRatio同级别)可选值:1K, 2K, 4K
原生协议
单图片输入
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/generateContent' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "USER",
"parts": [
{
"text": "{你的提示词文本}"
},
{
"inlineData": {
"data": "{你的图片base64编码数据}",
"mimeType": "{图片类型}"
}
}
]
}
],
"safetySettings": [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "OFF"
}
],
"generationConfig": {
"response_modalities": [
"TEXT",
"IMAGE"
],
"imageConfig": {
"aspectRatio": "4:3",
"imageSize": "1k"
}
}
}'
多图片输入
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/generateContent' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "USER",
"parts": [
{
"text": "{你的提示词文本}"
},
{
"inlineData": {
"data": "{你的图片base64编码数据}",
"mimeType": "image/png"
}
},
{
"inlineData": {
"data": "{你的图片base64编码数据}",
"mimeType": "image/png"
}
}
]
}
],
"safetySettings": [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "OFF"
}
],
"generationConfig": {
"response_modalities": [
"TEXT",
"IMAGE"
],
"imageConfig": {
"aspectRatio": "4:3",
"imageSize": "1k"
}
}
}'
请求响应
{
"modelVersion": "gemini-3-pro-image-preview",
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "Sure, here's how to make a classic peanut butter and jelly sandwich in three easy steps!\n\n**Step 1: Gather Your Ingredients and Tools**\nFirst, you'll need two slices of bread, peanut butter, your favorite jelly or jam, and a knife.\n"
},
{
"inlineData": {
"data": "",
"mimeType": "image/png"
}
},
{
"text": "\n**Step 2: Spread the Peanut Butter and Jelly**\nOn one slice of bread, generously spread peanut butter all the way to the edges. On the other slice, spread an even layer of jelly.\n"
},
{
"inlineData": {
"data": "",
"mimeType": "image/png"
}
}
]
},
"finishReason": "STOP"
}
],
"createTime": "2025-09-01T03:56:18.770244Z",
"usageMetadata": {
"candidatesTokenCount": 4031,
"totalTokenCount": 4049,
"trafficType": "ON_DEMAND",
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 18
}
],
"promptTokenCount": 18,
"candidatesTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 161
},
{
"modality": "IMAGE",
"tokenCount": 3870
}
]
},
"responseId": "Yhm1aMSBL9GIk7QPsqjR2Q4"
}
流式
请求
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/streamGenerateContent?alt=sse' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "USER",
"parts": {
"text": "Create a tutorial explaining how to make scrambled eggs with tomatoes in three steps."
}
}
],
"generationConfig": {
"response_modalities": [
"TEXT",
"IMAGE"
],
"imageConfig": {
"aspectRatio": "4:3",
"imageSize": "1k"
}
}
}'
响应
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": " breakfast.\n\n"
}
]
},
"avgLogprobs": -0.062918916344642639
}
],
"usageMetadata": {
"trafficType": "ON_DEMAND"
},
"modelVersion": "gemini-3-pro-image-preview",
"createTime": "2025-09-01T07:25:27.145810Z",
"responseId": "Z0q1aJLzCJO2z7sPmoe18A0"
}
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"inlineData": {
"mimeType": "image/png",
"data": ""
}
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 15,
"candidatesTokenCount": 4214,
"totalTokenCount": 4229,
"trafficType": "ON_DEMAND",
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 15
}
],
"candidatesTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 344
},
{
"modality": "IMAGE",
"tokenCount": 3870
}
]
},
"modelVersion": "gemini-3-pro-image-preview",
"createTime": "2025-09-01T07:25:27.145810Z",
"responseId": "Z0q1aJLzCJO2z7sPmoe18A0"
}
OpenAI协议
文本输入
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/chat/completions' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Create a tutorial explaining how to make scrambled eggs with tomatoes in three steps."
}
]
}
],
"imageConfig": {
"aspectRatio": "4:3",
"imageSize": "1k"
}
}'
多图片输入
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/chat/completions' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Create a tutorial explaining how to make scrambled eggs with tomatoes in three steps."
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,{data}"
}
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,{data}"
}
}
]
}
],
"imageConfig": {
"aspectRatio": "4:3",
"imageSize": "1k"
}
}'
响应
{
"id": "gen-1756460046-s9XKs4foyh6NgnCQvFz2",
"choices": [
{
"logprobs": null,
"finish_reason": "stop",
"native_finish_reason": "STOP",
"index": 0,
"message": {
"role": "assistant",
"content": "Here's a simple three-step tutorial for making delicious scrambled eggs with tomatoes!\n\n**Step 1: Prepare Your Ingredients**\n\nFirst, gather all your ingredients. You'll need two to three large eggs, a small tomato (or a few cherry tomatoes), a splash of milk or cream (optional, for fluffier eggs), a small pat of butter or a drizzle of olive oil, salt, and pepper. Dice your tomato into small, bite-sized pieces. In a bowl, whisk your eggs thoroughly with the milk/cream, salt, and pepper until the yolks and whites are fully combined and slightly frothy.\n\n\n\n**Step 2: Cook the Tomatoes and Eggs**\n\nHeat your butter or olive oil in a non-stick pan over medium-low heat. Once the pan is warm, add your diced tomatoes and sauté them for 1-2 minutes until they just begin to soften. Pour in your whisked eggs. Let them sit undisturbed for about 30 seconds to allow the edges to set slightly.\n\n**Step 3: Scramble and Serve**\n\nNow, using a spatula, gently push the cooked egg from the edges towards the center, tilting the pan to allow the uncooked egg to flow underneath. Continue this process, folding and pushing the eggs, until they are cooked to your desired consistency – soft and creamy. Be careful not to overcook them! Once done, immediately transfer your scrambled eggs with tomatoes to a plate. Serve hot and enjoy!\n\n",
"refusal": null,
"reasoning": null,
"images": [
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,"
},
"index": 0
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,"
},
"index": 1
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,"
},
"index": 2
}
]
}
}
],
"usage": {
"prompt_tokens": 1305,
"completion_tokens": 1328,
"total_tokens": 2633,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"image_tokens": 1290
}
}
}
流式
请求
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/chat/completions' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"stream": true,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Create a tutorial explaining how to make scrambled eggs with tomatoes in three steps."
}
]
}
],
"imageConfig": {
"aspectRatio": "4:3",
"imageSize": "1k"
}
}'
响应
{
"id": "chatcmpl-XzW9nHviU5bDMmLTF4VstiU8",
"choices": [
{
"delta": {
"role": "assistant",
"content": ""
},
"finish_reason": null,
"native_finish_reason": null,
"logprobs": null
}
],
"created": 1756795196,
"model": "MaaS_Ge_3_pro_image_preview_20251120",
"object": "chat.completion",
"usage": {
"prompt_tokens": 15,
"completion_tokens": 4129,
"total_tokens": 4144,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"image_tokens": 3870
}
}
}
{
"id": "chatcmpl-XzW9nHviU5bDMmLTF4VstiU8",
"choices": [
{
"delta": {
"role": "assistant",
"content": "",
"images": [
{
"type": "image_url",
"image_url": {
"url": ""
},
"index": 2
}
]
},
"finish_reason": "stop",
"native_finish_reason": "STOP",
"logprobs": null
}
]
}
MaaS_Ge_2.5_flash_image_preview
Gemini原生协议调用
1. 文生图
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT_PATH}/generateContent' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "USER",
"parts": {
"text": "生成一张电影效果照片,照片中有一栋大型建筑,建筑正面投影着巨大的文字:‘Gemini 2.5 现在可以生成长篇文本了"
}
}
],
"generationConfig": {
"response_modalities": [
"TEXT",
"IMAGE"
]
}
}'
2. 文生图-流式
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT_PATH}/streamGenerateContent' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "USER",
"parts": {
"text": "生成一张电影效果照片,照片中有一栋大型建筑,建筑正面投影着巨大的文字:‘Gemini 2.5 现在可以生成长篇文本了"
}
}
],
"generationConfig": {
"response_modalities": [
"TEXT",
"IMAGE"
]
}
}'
3. 图生图
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT_PATH}/generateContent' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "USER",
"parts": [
{
"text": "{你的提示词文本}"
},
{
"inlineData": {
"data": "{你的图片base64编码数据}",
"mimeType": "image/png"
}
},
{
"inlineData": {
"data": "{你的图片base64编码数据}",
"mimeType": "image/png"
}
}
]
}
],
"safetySettings": [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "OFF"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "OFF"
}
],
"generationConfig": {
"response_modalities": [
"TEXT",
"IMAGE"
]
}
}'
openai协议调用
4. openai格式:文生图
curl --request POST \
--url https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT_PATH}/chat/completions \
--header 'Accept: */*' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'User-Agent: PostmanRuntime-ApipostRuntime/1.1.0' \
--data '{
"model": "google/gemini-2.5-flash-image-preview",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Create a tutorial explaining how to make scrambled eggs with tomatoes in three steps."
}
]
}
]
}'
5. openai格式:文生图-流式
curl --request POST \
--url https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT_PATH}/chat/completions \
--header 'Accept: */*' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'User-Agent: PostmanRuntime-ApipostRuntime/1.1.0' \
--data '{
"model": "google/gemini-2.5-flash-image-preview",
"stream": true,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Create a tutorial explaining how to make scrambled eggs with tomatoes in three steps."
}
]
}
]
}'
6. openai格式:图生图
curl --location 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/chat/completions' \
--header 'Authorization: Bearer {YOUR_ACCESS_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"model": "google/gemini-2.5-flash-image-preview",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Create a tutorial explaining how to make scrambled eggs with tomatoes in three steps."
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,{data}"
}
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,{data}"
}
}
]
}
]
}'