curl --location 'https://4sapi.com/v1/chat/completions' \
--header 'Authorization: sk-**************************' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-3.1-flash-image-preview",
"stream": false,
"messages": [
{
"role": "user",
"content": "生成小猫图片"
}
],
"extra_body": {
"google": {
"image_config": {
"aspect_ratio": "16:9",
"image_size": "2K"
}
}
}
}'{
"id": "chatcmpl-202609140622102972281688268d9d6Hz00msr4",
"model": "gemini-3.1-flash-image-preview",
"object": "chat.completion",
"created": 1789366945,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "base64_code"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 2097,
"total_tokens": 2102,
"billing_usage": {
"source": "gemini_chat",
"semantic": "gemini",
"gemini_usage_metadata": {
"promptTokenCount": 5,
"toolUsePromptTokenCount": 0,
"candidatesTokenCount": 2097,
"totalTokenCount": 2102,
"thoughtsTokenCount": 0,
"cachedContentTokenCount": 0,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 5
}
],
"toolUsePromptTokensDetails": [],
"candidatesTokensDetails": [
{
"modality": "IMAGE",
"tokenCount": 1680
}
]
}
},
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 5,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"image_tokens": 1680,
"reasoning_tokens": 0
},
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": null,
"claude_cache_creation_5_m_tokens": 0,
"claude_cache_creation_1_h_tokens": 0
}
}