Skip to main content
POST
/
v1
/
images
/
generations
curl --request POST \
  --url https://models.rivus.cn/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gemini-3-pro-image-preview",
  "prompt": "A panda reading a book in the library, cinematic lighting",
  "size": "1024x1024",
  "response_format": "b64_json"
}
'
{
  "created": 1762789802,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
    }
  ]
}

生成图片

curl -X POST "$BASE_URL/v1/images/generations" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1",
    "prompt": "A futuristic skyline at dusk",
    "size": "1024x1024"
  }'
使用 openai 官方 Python SDK(通过 base_url 指向 Rivus AI 网关):
from openai import OpenAI

client = OpenAI(
    base_url="https://models.rivus.cn/v1",
    api_key="YOUR_API_KEY",
)

result = client.images.generate(
    model="gpt-image-1",
    prompt="A futuristic skyline at dusk",
    size="1024x1024",
)

# 默认返回图片 URL,可直接用于下载或在前端展示
print(result.data[0].url)

编辑图片

curl -X POST "$BASE_URL/v1/images/edits" \
  -H "Authorization: Bearer $TOKEN" \
  -F "model=gpt-image-1" \
  -F "image=@base.png" \
  -F "mask=@mask.png" \
  -F "prompt=在天空中加入热气球"

创建变体

curl -X POST "$BASE_URL/v1/images/variations" \
  -H "Authorization: Bearer $TOKEN" \
  -F "model=gpt-image-1" \
  -F "image=@origin.png"
所有接口均支持 nqualitybackground 等附加参数。若需返回 base64,可设置 response_format

Authorizations

Authorization
string
header
required

OpenAI 风格认证(Authorization: Bearer

Body

application/json
model
enum<string>
required

模型名称

Available options:
imagen-3.0-generate-001,
gemini-2.5-flash-image-preview,
gemini-3-pro-image-preview
Example:

"gemini-3-pro-image-preview"

prompt
string
required

图像描述文本

Maximum string length: 4000
Example:

"A futuristic cityscape at sunset with flying cars, cyberpunk style, highly detailed"

n
integer
default:1

生成图片数量(Imagen 支持 1-4,Gemini 仅支持 1)

Required range: 1 <= x <= 4
size
enum<string>
default:1024x1024

图像尺寸

Available options:
1024x1024,
1792x1024,
1024x1792
Example:

"1024x1024"

aspect_ratio
enum<string>

宽高比(优先级高于 size)

Available options:
1:1,
16:9,
9:16
Example:

"1:1"

response_format
enum<string>
default:url

响应格式

Available options:
url,
b64_json

Response

200 - application/json

图像生成成功

created
integer

创建时间戳

data
object[]