generateContent 接口生成图片。contents / partsgemini-2.5-flash-imageimage_response_format 在 base64 和 url 之间切换返回形式POST /v1/images/generations 的公开模型名封装Authorization: ********************{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Generate a square icon of a blue paper airplane on a white background."
}
]
}
],
"generationConfig": {
"responseModalities": [
"TEXT",
"IMAGE"
],
"imageConfig": {
"imageSize": "2K",
"aspectRatio": "1:1"
}
}
}curl --location --request POST 'https://api.ccapi.ai//v1beta/models/:generateContent?key=sk-xxxx' \
--header 'x-goog-api-key: sk-xxxx' \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Generate a square icon of a blue paper airplane on a white background."
}
]
}
],
"generationConfig": {
"responseModalities": [
"TEXT",
"IMAGE"
],
"imageConfig": {
"imageSize": "2K",
"aspectRatio": "1:1"
}
}
}'{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"inlineData": {
"mimeType": "image/png",
"data": "iVBORw0KGgoAAAANSUhEUgAA..."
}
},
{
"text": "Here is a generated image based on your prompt."
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 42,
"candidatesTokenCount": 2520,
"totalTokenCount": 2562
}
}