Ideogram V3 接口

Ideogram V3 模型提供了高級的圖像生成和處理能力。V3 接口與之前版本在參數和使用方式上有所不同,本節將詳細介紹 V3 的各個接口及使用示例。

V3 Generate

POST https://aihubmix.com/ideogram/v1/ideogram-v3/generate

根據給定提示詞生成圖像。V3 模型提供了更高质量的圖像生成能力,支持更豐富的風格和參數控制。

prompt
string
required

用於生成圖像的提示詞

rendering_speed
string
default:"DEFAULT"

渲染速度選項,可選 TURBO, DEFAULT, QUALITY

num_images
integer
default:"1"

單次出圖數量,範圍 1-8
增加圖片幾乎不會增加生圖耗時

aspect_ratio
string
default:"1x1"

用於圖像生成的宽高比,支持超多規格
可選 [‘1x3’, ‘3x1’, ‘1x2’, ‘2x1’, ‘9x16’, ‘16x9’, ‘10x16’, ‘16x10’, ‘2x3’, ‘3x2’, ‘3x4’, ‘4x3’, ‘4x5’, ‘5x4’, ‘1x1’]
和 V3 以下不同的模型使用的 ASPECT_10_16 類型的規範不同。

magic_prompt
string
default:"AUTO"

提示詞增強選項。可用參數:AUTO, ON, OFF

style_type
string
default:"AUTO"

生成圖像的風格類型,可選 AUTO, GENERAL, REALISTIC, DESIGN
注意相對 V2 版本,類型更聚焦

negative_prompt
string

描述不想在圖像中出現的内容

seed
integer

隨機種子,範圍:0-2147483647
單次生成多張圖時不要使用 seed,否則會生成相同圖像

style_reference_images
file

風格參考圖片,可用于風格引導

調用示例

curl -X POST https://aihubmix.com/ideogram/v1/ideogram-v3/generate \
  -H "Api-Key: sk-***" \
  -H "Content-Type: multipart/form-data" \
  -F prompt="Delicate 3D cover design with various combat machines flying from an portal. The machines have different shapes, sizes, and colors. The portal is emitting swirling energy. The background contains a futuristic city with tall buildings. The text \"One Gateway, Infinite Models\" is placed in the center with neon lights, expansive view, cinematic lighting, vivid color, bright tone. clean text, cyber punk, smooth render" \
  -F rendering_speed="QUALITY" \
  -F num_images="2" \
  -F aspect_ratio="2x1"

V3 Remix

POST https://aihubmix.com/ideogram/v1/ideogram-v3/remix

在參考圖的基礎上,根據提示詞重新生成圖像。V3 的 Remix 功能對原始圖像的風格和內容有更好的保留能力。

prompt
string
required

用於重繪圖像的提示詞

image
file
required

原始圖像文件

image_weight
integer
default:"50"

原圖的影響權重,範圍 1-100,數值越大,結果越像原圖。

rendering_speed
string
default:"DEFAULT"

渲染速度選項,可選 TURBO, DEFAULT, QUALITY

num_images
integer
default:"1"

單次出圖數量,範圍 1-8

aspect_ratio
string

輸出圖像的宽高比,可選 [‘1x3’, ‘3x1’, ‘1x2’, ‘2x1’, ‘9x16’, ‘16x9’, ‘10x16’, ‘16x10’, ‘2x3’, ‘3x2’, ‘3x4’, ‘4x3’, ‘4x5’, ‘5x4’, ‘1x1’]

style_reference_images
file

風格參考圖片,可用于風格引導

seed
integer

隨機種子,範圍:0-2147483647

magic_prompt
string
default:"AUTO"

提示詞增強選項,可用參數:AUTO, ON, OFF

style_type
string
default:"AUTO"

生成圖像的風格類型,可選 AUTO, GENERAL, REALISTIC, DESIGN

negative_prompt
string

描述不想在圖像中出現的内容

調用示例

import requests
import os

data = {
  "prompt": "bird playing with a cat in the snow, pixel art style",
  "image_weight": "60",
  "rendering_speed": "QUALITY",
  "num_images": 1,
  "seed": 1,
  "aspect_ratio": "16x9", 
  "magic_prompt": "AUTO",
  "style_type": "AUTO",
  "negative_prompt": "blurry, bad anatomy, watermark",
}

# 原圖 - 必填
source_image_path = "yourpath/image.jpeg"
if not os.path.exists(source_image_path):
    raise FileNotFoundError(f"源圖片未找到:{source_image_path}")

# initialize files parameter
files = None

# 樣式參考圖路徑
style_reference_path = "yourpath/reference-image.png"
use_reference_image = True

# 準備文件上傳
with open(source_image_path, "rb") as image_file:
    if use_reference_image and os.path.exists(style_reference_path):
        # 如果使用參考圖片且文件存在,則設置 files 參數
        files = {
            "image": image_file,
            "style_reference_images": open(style_reference_path, "rb"),
        }
    else:
        if use_reference_image:
            print(f"警告:樣式參考圖片未找到:{style_reference_path}")
        files = {
            "image": image_file,
        }

    response = requests.post(
      "https://aihubmix.com/ideogram/v1/ideogram-v3/remix",
      headers={
        "Api-Key": "sk-***" # 換成你在 AiHubMix 生成的密鑰
      },
      data=data,
      files=files
    )
print(response.json())

# save output image to file
response_json = response.json()
if response.ok and 'data' in response_json and len(response_json['data']) > 0:
    image_data = response_json['data'][0]['url']  # 正確獲取圖片 URL
    image_response = requests.get(image_data)
    if image_response.ok:
        with open('output.png', 'wb') as f:
            f.write(image_response.content)
        print("圖片已保存到 output.png")
    else:
        print(f"獲取圖片失敗:{image_response.status_code}")
else:
    print("API 請求失敗或返回數據中沒有圖片")
    print(f"錯誤詳情:{response_json}")

V3 Edit

POST https://aihubmix.com/ideogram/v1/ideogram-v3/edit

V3 的局部編輯功能允許用戶通過提供原始圖像和蒙版,精確地編輯圖像的特定區域,同時保持其他區域不變。

prompt
string
required

用於編輯圖像的提示詞

image
file
required

原始圖像文件

mask
file
required

遮罩圖片,黑色區域表示需要編輯的部分,白色區域表示保持不變

rendering_speed
string
default:"DEFAULT"

渲染速度選項,可選 TURBO, DEFAULT, QUALITY

num_images
integer
default:"1"

單次出圖數量,範圍 1-8

aspect_ratio
string

輸出圖像的宽高比

seed
integer

隨機種子,範圍:0-2147483647

magic_prompt
string
default:"AUTO"

提示詞增強選項,可用參數:AUTO, ON, OFF

style_type
string
default:"AUTO"

生成圖像的風格類型,可選 AUTO, GENERAL, REALISTIC, DESIGN

negative_prompt
string

描述不想在圖像中出現的内容

調用示例

import requests
import os

# 原圖 - 必填
source_image_path = "yourpath/image.jpeg"
# mask - 必填
mask_image_path = "yourpath/mask.jpg"

if not os.path.exists(source_image_path):
    raise FileNotFoundError(f"源圖片未找到:{source_image_path}")

with open(source_image_path, "rb") as image_file, open(mask_image_path, "rb") as mask_file:
    response = requests.post(
        "https://aihubmix.com/ideogram/v1/ideogram-v3/edit",
        headers={
            "Api-Key": "sk-***" # 換成你在 AiHubMix 生成的密鑰
        },
        data={
            "prompt": "remove text",
            "rendering_speed": "DEFAULT",
            "num_images": 1,
            "seed": 1,
            "aspect_ratio": "16x9",
            "magic_prompt": "AUTO",
            "style_type": "AUTO",
            "negative_prompt": "blurry, bad anatomy, watermark",
        },
        files={
            "image": image_file,
            "mask": mask_file,
        }
    )

print(response.json())

# save output image to file
response_json = response.json()
if response.ok and 'data' in response_json and len(response_json['data']) > 0:
    image_data = response_json['data'][0]['url']  # 正確獲取圖片 URL
    image_response = requests.get(image_data)
    if image_response.ok:
        with open('output.png', 'wb') as f:
            f.write(image_response.content)
        print("圖片已保存到 output.png")
    else:
        print(f"獲取圖片失敗:{image_response.status_code}")
else:
    print("API 請求失敗或返回數據中沒有圖片")
    print(f"錯誤詳情:{response_json}")

V3 Replace Background

POST https://aihubmix.com/ideogram/v1/ideogram-v3/replace-background

V3 的背景替換功能可以智能地識別圖像的前景和背景,並根據提示詞替換背景,同時保持前景對象不變。

prompt
string
required

用於替換背景的提示詞

image
file
required

原始圖像文件

rendering_speed
string
default:"DEFAULT"

渲染速度選項,可選 TURBO, DEFAULT, QUALITY

num_images
integer
default:"1"

單次出圖數量,範圍 1-8

style_reference_images
file

風格參考圖片,可用于風格引導

seed
integer

隨機種子,範圍:0-2147483647

magic_prompt
string
default:"AUTO"

提示詞增強選項,可用參數:AUTO, ON, OFF

style_type
string
default:"AUTO"

生成圖像的風格類型,可選 AUTO, GENERAL, REALISTIC, DESIGN

調用示例

import requests
import os

data = {
  "prompt": "bird playing with a cat in the snow, pixel art style",
  "rendering_speed": "QUALITY",
  "num_images": 1,
  "seed": 1,
  # no "aspect_ratio"
  "magic_prompt": "AUTO",
  "style_type": "AUTO",
  # no "negative_prompt"
}

# 原圖 - 必填
source_image_path = "yourpath/image.png"
if not os.path.exists(source_image_path):
    raise FileNotFoundError(f"源圖片未找到:{source_image_path}")

# initialize files parameter
files = None

# 樣式參考圖路徑
style_reference_path = "yourpath/reference-image.png"
use_reference_image = True

# 準備文件上傳
with open(source_image_path, "rb") as image_file:
    if use_reference_image and os.path.exists(style_reference_path):
        # 如果使用參考圖片且文件存在,則設置 files 參數
        files = {
            "image": image_file,
            "style_reference_images": open(style_reference_path, "rb"),
        }
    else:
        if use_reference_image:
            print(f"警告:樣式參考圖片未找到:{style_reference_path}")
        files = {
            "image": image_file,
        }

    response = requests.post(
      "https://aihubmix.com/ideogram/v1/ideogram-v3/replace-background",
      headers={
        "Api-Key": "sk-***" # 換成你在 AiHubMix 生成的密鑰
      },
      data=data,
      files=files
    )
print(response.json())

# save output image to file
response_json = response.json()
if response.ok and 'data' in response_json and len(response_json['data']) > 0:
    image_data = response_json['data'][0]['url']  # 正確獲取圖片 URL
    image_response = requests.get(image_data)
    if image_response.ok:
        with open('output.png', 'wb') as f:
            f.write(image_response.content)
        print("圖片已保存到 output.png")
    else:
        print(f"獲取圖片失敗:{image_response.status_code}")
else:
    print("API 請求失敗或返回數據中沒有圖片")
    print(f"錯誤詳情:{response_json}")

更多可選參數可參考 Ideogram AI 官方指南

💰 V3 計價

Ideogram 模型GenerateRemixEditReframeReplace BG
3.0 TurboUS $0.03US $0.03US $0.06US $0.06US $0.06
3.0 DefaultUS $0.06US $0.06US $0.06US $0.06US $0.06
3.0 QualityUS $0.09US $0.09US $0.09US $0.09US $0.09

V2-V1 接口說明

Ideogram AI V2-V1 繪圖接口,文字繪制能力強勁,支持生圖(generate)、混合(remix)、局部編輯(edit)、放大(upscale)和描述(describe)等。

  • 混合: 在參考圖的基礎上,根據提示詞進行重繪,生成新的圖片。
  • 編輯: 在參考圖的基礎上,根據提示詞和蒙版進行局部編輯,生成新的圖片。
  • 放大: 將低分辨率的圖片放大至高分辨率,會重繪細節(相似度和細節比例可控制)。
  • 描述: 提示詞反推,用於描述圖片

支持的風格:

  • AUTO:默認的自動選定
  • GENERAL:通用
  • REALISTIC:寫實
  • DESIGN:設計
  • RENDER_3D:3D
  • ANIME:動漫
  • 注意風格參數 style_type 僅適用於 V_2 及更高版本的模型。
  • V3 支持即將上線
  1. 支持通過 AiHubMix 官方接口調用或 Cherry Studio APP 使用,注意目前需要打開代理才能生圖,後續會支持國內直連,敬請期待。
  2. Cherry Studio 暫時只開放了 Ideogram 繪圖(generate)接口。

Generate

POST https://aihubmix.com/ideogram/generate\ 根據給定提示詞和可選參數同步生成圖像。圖像鏈接的有效期有限;如果你想保留圖像,必須下載保存。

Request Parameters

image_request
object
required

生成圖像的請求對象

image_request.prompt
string
required

用於生圖的提示詞

image_request.aspect_ratio
string
default:"ASPECT_1_1"

用於圖像生成的宽高比,決定了圖像的分辨率。不能與分辨率參數同時使用。

可用比例:

  • ASPECT_1_1
  • ASPECT_3_1
  • ASPECT_1_3
  • ASPECT_3_2
  • ASPECT_2_3
  • ASPECT_4_3
  • ASPECT_3_4
  • ASPECT_16_9
  • ASPECT_9_16
  • SPECT_16_10
  • ASPECT_10_16
image_request.model
string
default:"V_2"

用於生成或編輯圖像的模型。/generate 和 /remix 支持所有模型類型,但 /edit 僅支持 V_2 和 V_2_TURBO。

可用模型版本:

  • V_1
  • V_1_TURBO
  • V_2
  • V_2_TURBO
  • V_2A
  • V_2A_TURBO
image_request.magic_prompt_option
string
default:"AUTO"

提示詞增強選項。可用參數:AUTO, ON, OFF

image_request.seed
integer

隨機種子,範圍:0-2147483647

image_request.style_type
string
default:"AUTO"

生成圖像時使用的風格類型;此參數僅適用於 V_2 及更高版本的模型,不應在 V_1 版本中指定。

可用風格:

  • AUTO
  • GENERAL
  • REALISTIC
  • DESIGN
  • RENDER_3D
  • ANIME
image_request.negative_prompt
string

描述不想在圖像中出現的内容。僅適用於模型版本 V_1、V_1_TURBO、V_2 和 V_2_TURBO。提示詞中的描述優先級高於負面提示詞中的描述。

image_request.num_images
integer
default:"1"

單次出圖數量,範圍 1-8

image_request.resolution
string

用於圖像生成的分辨率(僅適用於模型版本 2.0,不能與 aspect_ratio 同時使用),以寬 x 高表示。如果未指定,則默認使用 aspect_ratio。

調用示例

import requests
import os

url = "https://aihubmix.com/ideogram/generate"

payload = { "image_request": {
        "prompt": "3D cartoon, An adorable white owl baby with tilted head, shiny amber eyes with highlight, fluffy body, standing on a trunk with moss and lots of glowing mushrooms, Close up, cinematic lighting, low angle, deep sense of depth. The background is a magical spring landscape, cute and esthetic, huge title design \"Always curious\"", #string 可選
        "negative_prompt": "blurry, bad anatomy, watermark",
        "aspect_ratio": "ASPECT_3_2",  # 可選 include ASPECT_1_1(Default), ASPECT_3_2, ASPECT_2_3, ASPECT_4_3, ASPECT_3_4, ASPECT_16_9, ASPECT_9_16, SPECT_16_10, ASPECT_10_16
        "model": "V_2",
        "num_images": 2, #integer 可選 >=1 <=8 Defaults to 1
        "magic_prompt_option": "AUTO", # string 可選 AUTO, ON, OFF
        #"seed": "2" #integer 可選 >=0 <=2147483647
        "style_type": "RENDER_3D" # string 可選 AUTO/GENERAL/REALISTIC/DESIGN/RENDER_3D/ANIME, 僅適用於 V_2 及以上版本
    } }
headers = {
    "Api-Key": os.getenv("AIHUBMIX_API_KEY"),
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())

Response

Image(s) generated successfully.

{
  "created": "2000-01-23T04:56:07Z",
  "data": [
    {
      "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there's an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.",
      "resolution": "1024x1024",
      "is_image_safe": true,
      "seed": 12345,
      "url": "https://ideogram.ai/api/images/direct/8YEpFzHuS-S6xXEGmCsf7g",
      "style_type": "REALISTIC"
    }
  ]
}

錯誤代碼

  • 400 : Post Generate Image Request Bad Request Error
  • 401 : Post Generate Image Request Unauthorized Error
  • 422 : Post Generate Image Request Unprocessable Entity Error
  • 429 : Post Generate Image Request Too Many Requests Error

Edit

POST https://aihubmix.com/ideogram/edit

使用提供的蒙版同步編輯指定圖像。蒙版標示出應被編輯的圖像部分,而提示詞和所選風格類型可進一步引導編輯方向。支持的圖像格式包括 JPEG、PNG 和 WebP。圖像鏈接的有效期有限;如果你想保留圖像,必須下載保存。

Request Parameters

image_file
file
required

原始圖像文件,支持 JPEG、PNG 和 WebP 格式

mask
file
required

遮罩圖片,黑色區域表示需要修改的部分,白色區域表示需要保持不變的部分

prompt
string
required

用於局部編輯的提示詞

model
string
required

用於生成或編輯圖像的模型。/generate 和 /remix 支持所有模型類型,但 /edit 僅支持 V_2 和 V_2_TURBO。

可用模型版本:

  • V_2
  • V_2_TURBO
magic_prompt_option
string
default:"AUTO"

提示詞增強選項。可用參數:AUTO, ON, OFF

num_images
integer
default:"1"

單次出圖數量,範圍 1-8

seed
integer

隨機種子,範圍:0-2147483647

style_type
string
default:"AUTO"

生成圖像時使用的風格類型;此參數僅適用於 V_2 及更高版本的模型。

可用風格:

  • AUTO
  • GENERAL
  • REALISTIC
  • DESIGN
  • RENDER_3D
  • ANIME

調用示例

import requests
import os

url = "https://aihubmix.com/ideogram/eidt"

files = {
    "image_file": open('<file1>', 'rb'), # 必須
    "mask": "open('<file1>', 'rb')" # 必須
}

payload = {
    "prompt": "\"prompt\"", # 必須
    "model": "V_2",  # 必須,only supported for V_2 and V_2_TURBO.
    "magic_prompt_option": ,
    "num_images":1, # integer 可選 >=1 <=8 Defaults to 1
    "seed": , # integer 可選 >=0 <=2147483647
    "style_type":
16}
headers = {"Api-Key": os.getenv("AIHUBMIX_API_KEY")}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json()

# close file
files["image_file"].close()
files["mask"].close()

Response

Image edits generated successfully.

{
  "created": "2000-01-23T04:56:07Z",
  "data": [
    {
      "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there's an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.",
      "resolution": "1024x1024",
      "is_image_safe": true,
      "seed": 12345,
      "url": "https://ideogram.ai/api/images/direct/8YEpFzHuS-S6xXEGmCsf7g",
      "style_type": "REALISTIC"
    }
  ]
}

錯誤代碼

  • 400 : Post Edit Image Request Bad Request Error
  • 401 : Post Edit Image Request Unauthorized Error
  • 422 : Post Edit Image Request Unprocessable Entity Error
  • 429 : Post Edit Image Request Too Many Requests Error

Remix

POST https://aihubmix.com/ideogram/remix

根據給定提示詞和可選參數來融合提供的圖像。輸入圖像會在重混前裁剪至所選宽高比。支持的圖像格式包括 JPEG、PNG 和 WebP。圖像鏈接的有效期有限;如果你想保留圖像,必須下載保存。

Request Parameters

image_request
object
required

使用提供的圖像和提示詞生成新圖像的請求,提供的圖像會被裁剪以匹配所選的輸出宽高比。

image_request.prompt
string
required

用於生成圖像的提示詞

image_request.aspect_ratio
string
default:"ASPECT_1_1"

用於圖像生成的宽高比,決定了圖像的分辨率。不能與分辨率參數同時使用。

可用比例:

  • ASPECT_1_1
  • ASPECT_3_1
  • ASPECT_1_3
  • ASPECT_3_2
  • ASPECT_2_3
  • ASPECT_4_3
  • ASPECT_3_4
  • ASPECT_16_9
  • ASPECT_9_16
  • SPECT_16_10
  • ASPECT_10_16
image_request.image_weight
integer
default:"50"

參考圖權重,範圍:1-100

image_request.model
string
default:"V_2"

用於生成或編輯圖像的模型。/generate 和 /remix 支持所有模型類型,但 /edit 僅支持 V_2 和 V_2_TURBO。

image_request.negative_prompt
string

描述不想在圖像中出現的内容。僅適用於模型版本 V_1、V_1_TURBO、V_2 和 V_2_TURBO。提示詞中的描述優先級高於負面提示詞中的描述。

image_request.magic_prompt_option
string
default:"AUTO"

提示詞增強選項。可用參數:AUTO, ON, OFF

image_request.num_images
integer
default:"1"

單次出圖數量,範圍:1-8

image_request.resolution
string

用於圖像生成的分辨率(僅適用於模型版本 2.0,不能與 aspect_ratio 同時使用),以寬 x 高表示。如果未指定,則默認使用 aspect_ratio。

image_request.seed
integer

隨機種子,範圍:0-2147483647

image_request.style_type
string
default:"AUTO"

生成圖像的風格類型;僅適用於 V_2 及以上版本的模型,不應在 V_1 版本中指定。

可用風格:

  • AUTO
  • GENERAL
  • REALISTIC
  • DESIGN
  • RENDER_3D
  • ANIME
image_file
file
required

原始圖像文件,支持 JPEG、PNG 和 WebP 格式

調用示例

import requests
import os

url = "https://aihubmix.com/ideogram/remix"

files = { "image_file": open('<file1>', 'rb') }
payload = {"image_request": '''{
    "prompt": "watercolor",
    "aspect_ratio": "ASPECT_10_16",
    "image_weight": 50,
    "magic_prompt_option": "ON",
    "model": "V_2"
}'''}

headers = {"Api-Key": os.getenv("AIHUBMIX_API_KEY")}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json())

Response

Image(s) generated successfully.

{
  "created": "2000-01-23T04:56:07Z",
  "data": [
    {
      "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there's an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.",
      "resolution": "1024x1024",
      "is_image_safe": true,
      "seed": 12345,
      "url": "https://ideogram.ai/api/images/direct/8YEpFzHuS-S6xXEGmCsf7g",
      "style_type": "REALISTIC"
    }
  ]
}

錯誤代碼

  • 400 : Post Remix Image Request Bad Request Error
  • 401 : Post Remix Image Request Unauthorized Error
  • 422 : Post Remix Image Request Unprocessable Entity Error
  • 429 : Post Remix Image Request Too Many Requests Error

Upscale

POST https://aihubmix.com/ideogram/upscale

使用可選提示詞同步放大提供的圖像(超分)。支持的圖像格式包括 JPEG、PNG 和 WebP。圖像鏈接的有效期有限;如果你想保留圖像,必須下載保存。

Request Parameters

image_request
object
required

請求對象,用於使用可選提示詞放大提供的圖像

image_request.prompt
string

可選的提示詞,用於引導放大過程

image_request.resemblance
integer
default:"50"

相似度,範圍:1-100

image_request.detail
integer
default:"50"

細節,範圍:1-100

image_request.magic_prompt_option
string
default:"AUTO"

提示詞增強選項。可用參數:AUTO, ON, OFF

image_request.num_images
integer
default:"1"

生成數量,範圍:1-8

image_request.seed
integer

隨機種子,範圍:0-2147483647

image_file
file
required

原始圖像文件,支持 JPEG、PNG 和 WebP 格式

調用示例

import requests
import os

url = "https://aihubmix.com/ideogram/upscale"

files = { "image_file": open('<file1>', 'rb') }
payload = { "image_request": "{}" }
headers = {"Api-Key": os.getenv("AIHUBMIX_API_KEY")}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json())

Response

Image(s) generated successfully.

{
  "created": "2000-01-23T04:56:07Z",
  "data": [
    {
      "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there's an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.",
      "resolution": "1024x1024",
      "is_image_safe": true,
      "seed": 12345,
      "url": "https://ideogram.ai/api/images/direct/8YEpFzHuS-S6xXEGmCsf7g",
      "style_type": "REALISTIC"
    }
  ]
}

錯誤代碼

  • 400 : Post Upscale Image Request Bad Request Error
  • 401 : Post Upscale Image Request Unauthorized Error
  • 422 : Post Upscale Image Request Unprocessable Entity Error
  • 429 : Post Upscale Image Request Too Many Requests Error

Describe

POST https://aihubmix.com/ideogram/describe

對上傳的圖像進行描述分析。支持的圖像格式包括 JPEG、PNG 和 WebP。

Request Parameters

image_file
file
required

需要描述的圖像文件,支持 JPEG、PNG 和 WebP 格式

調用示例

import requests
import os

url = "https://aihubmix.com/ideogram/describe"

files = { "image_file": open('<file1>', 'rb') }
headers = {"Api-Key": os.getenv("AIHUBMIX_API_KEY")}

response = requests.post(url, files=files, headers=headers)

print(response.json())

# close file
files["image_file"].close()

Response

Description(s) created successfully.

{
  "descriptions": [
    {
      "text": "A meticulously illustrated cat with striped patterns, sitting upright. The cat's eyes are a captivating shade of yellow, and it appears to be gazing intently at something. The background consists of abstract, swirling patterns in shades of black, white, and beige, creating an almost fluid or wavy appearance. The cat is positioned in the foreground, with the background elements fading into the distance, giving a sense of depth to the image."
    },
    {
      "text": "A meticulously illustrated cat with striped patterns, sitting upright. The cat's eyes are a captivating shade of yellow, and it appears to be gazing intently at something. The background consists of abstract, swirling patterns in shades of black, white, and beige, creating an almost fluid or wavy appearance. The cat is positioned in the foreground, with the background elements fading into the distance, giving a sense of depth to the image."
    }
  ]
}

錯誤代碼

  • 400 : Post Describe Request Bad Request Error
  • 422 : Post Describe Request Unprocessable Entity Error
  • 429 : Post Describe Request Too Many Requests Error

💰 V2 & V1 計價

圖像生成

型號功能每張圖片費用
2a文字生圖,或文字 + 參考圖生圖US $0.04
2a Turbo文字生圖,或文字 + 參考圖生圖(更快速但質量略低)US $0.025
2.0文字生圖,或文字 + 參考圖生圖US $0.08
2.0 Turbo文字生圖,或文字 + 參考圖生圖(更快速但質量略低)US $0.05
1.0文字生圖,或文字 + 參考圖生圖US $0.06
1.0 Turbo文字生圖,或文字 + 參考圖生圖(更快速但質量略低)US $0.02

圖像編輯

型號功能每張圖片費用
2.0 Edit通過文字提示、參考圖片和二進制蒙版重新生成圖像US $0.08
2.0 Turbo Edit通過文字提示、參考圖片和二進制蒙版重新生成圖像(更快速但質量略低)US $0.05

圖像增強

型號功能每張圖片費用
Upscale將參考圖片分辨率提升至 2 倍,並可能增強圖片效果US $0.06

更多詳情可見官方文件