Gemini 3.1 Flash Image
Describes how `gemini-3.1-flash-image-preview` is integrated in the current project: it belongs to the Gemini native model and does not use the unified image interface.
- The current project does not expose this model through
POST /v1/images/generations - This model is accessed via the Gemini native model interface in the project
- The calling route should use
POST /v1beta/models/{model}:{action}
Recommended Route
POST /v1beta/models/gemini-3.1-flash-image-preview:{action}Common actions:
generateContentstreamGenerateContent
Ready-to-Use Call Examples
cURL
curl --request POST \
--url https://api.magickapi.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "生成一张赛博朋克风格的城市夜景。"
}
]
}
]
}'Python
import json
import requests
url = "https://api.magickapi.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"contents": [
{
"role": "user",
"parts": [
{
"text": "生成一张赛博朋克风格的城市夜景。"
}
],
}
]
}
response = requests.post(url, headers=headers, json=payload, timeout=300)
response.raise_for_status()
result = response.json()
print(json.dumps(result, ensure_ascii=False, indent=2))Node.js
const url =
"https://api.magickapi.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent";
const payload = {
contents: [
{
role: "user",
parts: [
{
text: "生成一张赛博朋克风格的城市夜景。",
},
],
},
],
};
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(await response.text());
}
const result = await response.json();
console.log(JSON.stringify(result, null, 2));Response Description
This model returns the Gemini native JSON structure and will not be converted to the unified image interface format:
{
"data": [
{
"url": "..."
}
]
}Please parse the specific output structure according to the Gemini native protocol and refer to the "General Models / Gemini Native Format" page.
Last updated on
Grok Imagine Image Generation
Call xAI image models through the unified image API; the current project returns a synchronous `ImageResponse` and does not support the legacy task_id polling documentation.
Veo Video Generation
Call Veo models through the unified video task interface; describes available models, request fields, and query methods in the current project.