外观
Gemini 3.1 Flash Image Preview
gemini-3.1-flash-image-preview 是 Gemini 3.1 Flash 图片生成与编辑模型。请使用规范 Gemini 模型 id,并通过 size 传入输出比例。
API 形式
| 操作 | Endpoint | 模式 |
|---|---|---|
| 图片生成 | POST /v1/images/generations | 同步 |
| 图片生成任务 | POST /v1/async/images/generations | 异步 |
| 图片编辑 | POST /v1/images/edits | 同步 |
| 图片编辑任务 | POST /v1/async/images/edits | 异步 |
价格
积分
| 模型 id | 输出档位 | 每张积分 |
|---|---|---|
gemini-3.1-flash-image-preview-512 | 512px | 4 |
gemini-3.1-flash-image-preview | 1K(1024px) | 4 |
gemini-3.1-flash-image-preview-2k | 2K(2048px) | 6 |
gemini-3.1-flash-image-preview-4k | 4K(4096px) | 8 |
请求字段
该模型与 Pixapi 其他图片模型一样,使用 OpenAI 兼容图片字段。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 使用 gemini-3.1-flash-image-preview。 |
prompt | string | 是 | 描述要生成或编辑的图片。 |
image | string 或 string[] | 编辑必填 | 输入图片 URL;支持多参考图时可传图片 URL 数组。 |
n | number | 否 | 返回图片数量,当前仅支持传 1。 |
size | string | 否 | 输出比例:1:1、16:9、9:16、4:3、3:4、2:3、3:2、4:5、5:4、21:9、1:4、4:1、8:1 或 1:8。 |
示例
bash
curl https://api.pixapi.ai/v1/images/generations \
-H "Authorization: Bearer $PIXAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.1-flash-image-preview",
"prompt": "A polished product photo of a ceramic coffee cup",
"n": 1,
"size": "1:1"
}'py
import os
import requests
response = requests.post(
"https://api.pixapi.ai/v1/images/generations",
headers={
"Authorization": f"Bearer {os.environ['PIXAPI_KEY']}",
"Content-Type": "application/json",
},
json={
"model": "gemini-3.1-flash-image-preview",
"prompt": "A polished product photo of a ceramic coffee cup",
"n": 1,
"size": "1:1"
},
)
response.raise_for_status()
print(response.json())js
const response = await fetch('https://api.pixapi.ai/v1/images/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PIXAPI_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"model": "gemini-3.1-flash-image-preview",
"prompt": "A polished product photo of a ceramic coffee cup",
"n": 1,
"size": "1:1"
}),
});
if (!response.ok) {
throw new Error(await response.text());
}
console.log(await response.json());go
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{
"model": "gemini-3.1-flash-image-preview",
"prompt": "A polished product photo of a ceramic coffee cup",
"n": 1,
"size": "1:1"
}`)
req, err := http.NewRequest(
"POST",
"https://api.pixapi.ai/v1/images/generations",
bytes.NewBuffer(body),
)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("PIXAPI_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}共享响应结构和图片编辑上传示例见 API 参考。
