主题
图像(Images)
AI 图像生成与编辑接口。
生成图像 POST
text
POST https://api.nassaapi.xyz/images/generations请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | ✅ | 模型 ID,如 dall-e-3 / gemini-2.5-flash-image |
prompt | string | ✅ | 图片描述 |
n | int | ❌ | 生成数量,默认 1 |
size | string | ❌ | 1024x1024 / 1792x1024 / 1024x1792 |
quality | string | ❌ | standard / hd |
response_format | string | ❌ | url(默认) / b64_json |
示例请求
bash
curl -X POST "https://api.nassaapi.xyz/images/generations" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxx" \
-d '{
"model": "dall-e-3",
"prompt": "一只可爱的猫咪坐在窗台上看雪景,水彩画风格",
"n": 1,
"size": "1024x1024"
}'python
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxx",
base_url="https://api.nassaapi.xyz"
)
response = client.images.generate(
model="dall-e-3",
prompt="一只可爱的猫咪坐在窗台上看雪景,水彩画风格",
n=1,
size="1024x1024"
)
print(response.data[0].url)javascript
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-xxxx',
baseURL: 'https://api.nassaapi.xyz',
});
const response = await client.images.generate({
model: 'dall-e-3',
prompt: '一只可爱的猫咪坐在窗台上看雪景,水彩画风格',
n: 1,
size: '1024x1024',
});
console.log(response.data[0].url);响应
json
{
"created": 1700000000,
"data": [
{
"url": "https://...",
"revised_prompt": "A cute cat sitting on a windowsill watching snowfall..."
}
]
}编辑图像 POST
text
POST https://api.nassaapi.xyz/images/edits请求参数
基于原图 + mask + 文字提示,实现「换背景 / 换衣服 / 加物品」等局部编辑。
bash
curl -X POST "https://api.nassaapi.xyz/images/edits" \
-H "Authorization: Bearer sk-xxxx" \
-F image=@input.png \
-F mask=@mask.png \
-F prompt="把背景换成樱花树下" \
-F model="gemini-2.5-flash-image" \
-F n=1 \
-F size="1024x1024"提示:mask.png 必须是 PNG 透明图,透明区域即要被替换的位置。