1.原生协议请求:https://api.yisu.com/v1/ai/{ENDPOINT}/generateContent
2.OpenAI协议请求:https://api.yisu.com/v1/ai/{ENDPOINT}/chat/completions
参数aspect_ratio可选值:”1:1”, “2:3”, “3:2”, “3:4”, “4:3”, “4:5”, “5:4”, “9:16”, “16:9”, “21:9”。说明:控制生成图片的宽高比。默认按模型预设处理。
参数imageSize可选值:1K, 2K, 4K。
说明:控制输出图片的大致分辨率。
curl --location 'https://api.yisu.com/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://api.yisu.com/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://api.yisu.com/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"}
curl --location 'https://api.yisu.com/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://api.yisu.com/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://api.yisu.com/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}]}