Nano Banana API:$0.01$0.04(75% 优惠)
菜单
ImageGPT AI API

API 文档

使用我们强大的 AI 模型将您的创意转化为精美图像和视频

直接图像生成 API 测试场

测试并探索支持多种模型和输出格式的图像生成 API

选择模型

端点

POSThttps://api.imagegpt.online/generate/text-image

请求头

请求体

代码示例

fetch('https://api.imagegpt.online/generate/text-image', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
  "prompt": "Photorealistic portrait of the same person (keep his real face unchanged). A man with medium curly brown hair, light skin, and soft features sits relaxed, forearms on a light blue table, holding a small white puppy with a red collar. He wears a cozy color-block knitted sweater (beige, tan, light blue, black) with ribbed neck and cuffs, a silver watch, and a turquoise-beaded bracelet. Soft diffused lighting, smooth steel-blue background, slightly elevated front angle warm, intimate, digital photo",
  "width": 512,
  "height": 512,
  "model": "FLUX-SCHNELL",
  "outputType": "binary",
  "outputFormat": "png"
})
})
  .then(response => response.blob())
  .then(blob => {
    const imageUrl = URL.createObjectURL(blob);
    console.log('Image URL:', imageUrl);
    // Display in img tag: document.getElementById('myImg').src = imageUrl;
  })
  .catch(error => console.error('Error:', error));
API文档

图像生成API

使用15+个AI模型的统一REST API — 支持文生图和图生图,多种输出格式,积分定价。

POSThttps://api.imagegpt.online/generate/text-image

所有请求必须在请求头中包含API密钥。请保密您的API密钥。

http header
x-api-key: YOUR_API_KEY

缺失或无效的API密钥返回 401 Unauthorized 响应。

发送包含以下字段的JSON请求体:

参数类型默认值描述
model*
string—用于生成的模型ID。
prompt*
string—想要生成的图像的文本描述。
width
number512输出图像宽度(像素)。
height
number512输出图像高度(像素)。
outputType
string"binary"输出格式:"binary"、"url"或"base64"。
outputFormat
string"png"图像文件格式:"png"或"jpg"。
image
string[]—输入图像URL数组(最多3个)。仅图生图时必填。

* 必填字段。

响应形状取决于您选择的 outputType :

binary

outputType: "binary"

js
const blob = await response.blob();
const url = URL.createObjectURL(blob);
url

outputType: "url"

json
{
  "success": true,
  "taskId": "imagegpt_img-...",
  "url": "https://...",
  "creditsDeducted": 3
}
base64

outputType: "base64"

json
{
  "success": true,
  "taskId": "imagegpt_img-...",
  "base64": "/9j/4QWm...",
  "creditsDeducted": 3
}

使用fetch API的最小文生图请求:

javascript
fetch('https://api.imagegpt.online/generate/text-image', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
    model: 'FLUX-SCHNELL',
    prompt: 'A futuristic city at sunset, photorealistic',
    width: 512,
    height: 512,
    outputType: 'url',
    outputFormat: 'png'
  })
})
  .then(res => res.json())
  .then(data => console.log('Image URL:', data.url));

对于图生图,添加 image 数组:

javascript
body: JSON.stringify({
  model: 'FLUX-KONTEXT',
  prompt: 'Same person, wearing a red jacket',
  image: ['https://example.com/input.jpg'],
  width: 512,
  height: 512,
  outputType: 'url',
  outputFormat: 'png'
})

积分按每张生成的图像收费:

经济型
3积分 / 图像

适合草稿的快速轻量模型。

e.g. Flux Schnell, Z Image Turbo

标准型
10–30积分 / 图像

日常生成任务的均衡品质。

e.g. GPT Image 1.0, Seedream, Nova Canvas

高级型
35–100积分 / 图像

生产级输出的最高保真度。

e.g. Nano Banana Pro, Seedream 4.0, Ideogram

ImageGPT 禁止 NSFW、色情、成人、剥削性、欺骗性或有害的 AI 生成内容。内容审核适用于受支持的图像和视频生成。