深色模式
图片生成
图片模型需要使用 image 分组(GPT Image、Gemini 图像 / Nano Banana)或 seedream 分组(火山 Seedream)的密钥。图片模型按张计费,价格见 定价页。
GPT Image
bash
curl https://aimoniker.top/v1/images/generations \
-H "Authorization: Bearer sk-xxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "一只戴着宇航员头盔的橘猫,漂浮在太空站里,写实风格",
"size": "1024x1024",
"n": 1
}'python
from openai import OpenAI
import base64
client = OpenAI(api_key="sk-xxxx", base_url="https://aimoniker.top/v1")
result = client.images.generate(
model="gpt-image-2",
prompt="一只戴着宇航员头盔的橘猫,漂浮在太空站里,写实风格",
size="1024x1024",
)
with open("cat.png", "wb") as f:
f.write(base64.b64decode(result.data[0].b64_json))返回结果中,图片为 b64_json(Base64)或 url,取决于模型。
图片编辑(垫图)
bash
curl https://aimoniker.top/v1/images/edits \
-H "Authorization: Bearer sk-xxxx" \
-F model=gpt-image-2 \
-F image=@input.png \
-F prompt="把背景换成海边日落"Gemini 图像(Nano Banana)
使用 Gemini 原生接口,在 generationConfig 中要求返回图片:
bash
curl "https://aimoniker.top/v1beta/models/gemini-3-pro-image:generateContent" \
-H "x-goog-api-key: sk-xxxx" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "画一张赛博朋克风格的城市夜景"}]}],
"generationConfig": {"responseModalities": ["TEXT", "IMAGE"]}
}'图片以 Base64 形式在 candidates[0].content.parts[].inlineData.data 中返回。
不想写代码?
试试 无限画布,在网页上直接生成和编辑图片。
