接口说明

为满足用户的强烈需求,我们特别推出了两个逆向接口:gpt-4o-imagegpt-4o-image-vip。其中,VIP 模型在性能和稳定性方面表现更为出色。
请注意,这些逆向接口无法保证完全稳定,可能会出现 🕐 Queuing... 排队状态或生成失败的情况,因此建议仅将其用于体验新功能或进行测试。
鉴于 OpenAI 已正式发布 gpt-image-1 接口,考虑到调用成本因素,我们将暂时保留这些逆向接口,并提供完全兼容的调用方式。

注意事项

  • 生成过程中,无论任何情况导致的中断或失败,接口调用一经发出,都会被扣取费用
  • 还在世的艺术家名称(如「宫崎骏」、「新海诚」等)会触发 input_moderation 报错,导致生成失败。你可以通过「吉卜力」、「明亮的现代日式动漫风格」等非敏感词来规避
  • 总的来说,「风格」比「艺术家」安全,像是「皮克斯」也是支持的
  • 更稳妥的做法是采用已故艺术家或对应的风格,如「梵高」、「蒙娜丽莎」等

模型和费率

模型后台扣费 (美元/次)约 (人民币/次)
gpt-4o-image-vip$0.009折合约 ¥0.06
gpt-4o-image$0.005折合约 ¥0.04
  1. 后台费率以美元为准。
  2. 由于逆向接口的维护成本上升,单次调用的价格已经上调。(更新日期:20250604)
  3. 正式的 gpt-image-1 输入文本 Token 部分的费率是 $5/百万 Tokens,逆向接口只按图片绘制次数计算。

Python 调用示例

使用大家熟悉的 v1/completions 端点来提供支持,完美兼容,具体使用可以参考:

from openai import OpenAI

client = OpenAI(
    api_key="AIHUBMIX_API_KEY", # 换成你在后台生成的 Key "sk-***"
    base_url="https://aihubmix.com/v1"
)

# 创建聊天完成请求
stream = client.chat.completions.create(
    model="gpt-4o-image-vip", #list: gpt-4o-image-vip, gpt-4o-image
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": """Redesign [Girl wearing a pearl earring] as an anime-style illustrated cover. Preserve original essence and composition. Render in refined Kyoto Anime-inspired style—soft brushwork, cinematic lighting, progressive depth. 
Format in AV cover layout: 
Japanese-English mixed typography, serif title with significant visual hierarchy - sense of design is the key.
Extract words tha conveys profound meanings as title, then creative slogan, the original name can be a smaller information ONLY if necessary.
Subtly embed watermark "jerlin" in clothing or background. Maintain emotional tone and posture, soften only when necessary. 2:3 portrait"""
                }
            ]
        }
    ],
    stream=True
)

# 使用 for 循环处理流式响应
for chunk in stream:
    try:
        if chunk.choices and len(chunk.choices) > 0 and chunk.choices[0].delta and chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content, end="", flush=True)
    except Exception as e:
        print(f"\n处理响应时出现错误:{str(e)}")

输出示例

{
  "prompt": "Redesign 'Girl with a Pearl Earring' as an anime-style illustrated cover. Preserve the original essence and composition: the iconic side-glance pose, serene expression, and intimate framing. Render in refined Kyoto Anime-inspired style with soft brushwork, cinematic lighting, and progressive depth. Create an AV cover layout with Japanese-English mixed typography, using a prominent serif title with strong visual hierarchy. Extract profound words for the title and include a creative slogan. The original name 'Girl with a Pearl Earring' should appear as smaller text if needed. Subtly embed the watermark 'jerlin' in clothing or background. For modesty, replace any potential nudity with flowing fabric, hair, or veils while maintaining the emotional tone and posture. Soften details only when necessary.",
  "ratio": "2:3"
}

>🕐 Queuing.

>⚡ Generating.....

>🏃‍ Progress 11....19....27...34....42....50....57...64....[100](https://videos.openai.com/vg-assets/assets%2Ftask_01jsccq77nfcsab7dn8bx7z230%2Fsrc_1.png?st=2025-04-21T13%3A08%3A48Z&se=2025-04-27T14%3A08%3A48Z&sks=b&skt=2025-04-21T13%3A08%3A48Z&ske=2025-04-27T14%3A08%3A48Z&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skoid=aa5ddad1-c91a-4f0a-9aca-e20682cc8969&skv=2019-02-02&sv=2018-11-09&sr=b&sp=r&spr=https%2Chttp&sig=xm6K6M7au3F3Vd9qcYxR3mYWrqAHsgbagbUV5GQo39w%3D&az=oaivgprodscus)

> ✅ Generation complete


![gen_01jsccq83pfg6ssfqf3pzfaytj](https://filesystem.site/cdn/20250421/XBCrAs6qvMARG7BkFX0KI3MBs1qoto.png)

[Click to download](https://filesystem.site/cdn/download/20250421/XBCrAs6qvMARG7BkFX0KI3MBs1qoto.png)

![gen_01jsccq83nf6ftmtx8y48h383y](https://filesystem.site/cdn/20250421/tQ62gh0BbdESApNmFJMNzsdUFDflkl.png)

[Click to download](https://filesystem.site/cdn/download/20250421/tQ62gh0BbdESApNmFJMNzsdUFDflkl.png)%

OpenAI 正式接口兼容

如果你更偏好 OpenAI 最新发布的 Image generation 调用方式,可以参考以下处理,注意 3 点即可:

  1. 不能传质量参数,模型 gpt-4o-image-vipgpt-4o-image 自身捆绑了
  2. 不支持打印追踪 Token 用量的 usage 字段
  3. 最新的输出是 Base64 图片数据,用例已经做了自动保存
Python
from openai import OpenAI
import os
import requests
import base64

client = OpenAI(
    api_key="AIHUBMIX_API_KEY", # 替换成你的 AiHubMix 密钥
    base_url="https://aihubmix.com/v1"
)

prompt = """
redesign poster of the movie [Black Swam], 3D cartoon, smooth render, bright tone, 2:3
"""

result = client.images.generate(
    model="gpt-4o-image-vip",
    prompt=prompt,
    n=1, # 单次数量
    size="1024x1536", # 1024x1024 (square), 1536x1024 (3:2 landscape), 1024x1536 (2:3 portrait), auto (default)
    #quality="high" # 逆向模型不能传质量参数,模型捆绑了 📍
)

print(result) # 打印完整的 API 响应,逆向接口不支持 usage 📍

# 定义文件名前缀和保存目录
output_dir = "." # 可以指定其他目录
file_prefix = "image_gen-逆向"

# 确保输出目录存在
os.makedirs(output_dir, exist_ok=True)

# 遍历所有返回的图片数据
for i, image_data in enumerate(result.data):
    # 优先处理 base64 字符串
    if hasattr(image_data, "b64_json") and image_data.b64_json:
        image_bytes = base64.b64decode(image_data.b64_json)
        current_index = i
        while True:
            file_name = f"{file_prefix}_{current_index}.png"
            file_path = os.path.join(output_dir, file_name)
            if not os.path.exists(file_path):
                break
            current_index += 1
        with open(file_path, "wb") as f:
            f.write(image_bytes)
        print(f"图片已保存至:{file_path} (base64)")
    # 其次处理 url 字段(保留稳健处理,防止兼容接口再变更)
    elif hasattr(image_data, "url") and image_data.url:
        try:
            response = requests.get(image_data.url, stream=True)
            response.raise_for_status()
            image_bytes = response.content
            current_index = i
            while True:
                file_name = f"{file_prefix}_{current_index}.png"
                file_path = os.path.join(output_dir, file_name)
                if not os.path.exists(file_path):
                    break
                current_index += 1
            with open(file_path, "wb") as f:
                f.write(image_bytes)
            print(f"图片已保存至:{file_path} (url)")
        except requests.exceptions.RequestException as e:
            print(f"下载第 {i} 张图片失败:{e}")
        except Exception as e:
            print(f"处理第 {i} 张图片时发生错误:{e}")
    else:
        print(f"第 {i} 张图片数据中既无 b64_json 也无 url,跳过保存。")

效果展示

Girl-with-a-Pearl-Earring

戴珍珠项链的女孩

  1. 名画重演绎,带排版和水印直出。
pixar

皮克斯卡通

  1. 皮克斯 3D 卡通风格,稳如老狗。
ghibli

3D

  1. 最受欢迎的吉卜力

实用提示

  • 支持任何语言,中文绘制也很稳定,但我们也不建议绘制大量的文本。
  • 画幅比例在 prompt 中指定,否则 4o 自动判断。支持 2:3、3:2、1:1。
  • 没有灵感就给参考图,支持单图和多图。
  • 上传的图片可以做压缩预处理,提升速度。
  • 支持透明背景,免抠图。——只需要在 Prompt 中补充要求。