接口说明

由于 OpenAI 官方迟迟不开放 GPT-4o 绘图接口,为满足广大用户的强烈期待,我们特别上线了两个逆向接口:gpt-4o-imagegpt-4o-image-vip。其中,VIP 模型在性能与稳定性上更具优势。
请注意,逆向接口在稳定性方面无法提供完全保障,可能陷入 🕐 Queuing... 排队状态或生成失败,建议仅用于尝鲜体验与功能测试。 未来,一旦 OpenAI 官方正式发布 GPT-4o 绘图 API,我们将立即下线当前逆向接口,并无缝迁移至官方稳定版本。

注意事项

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

模型和费率

模型费用 (人民币/次)
gpt-4o-image-vip折合约 ¥0.05
gpt-4o-image折合约 ¥0.02

后台费率以美元为准

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. 输出结果是 URL 链接,不是图片,用例已经做了自动保存
Python
from openai import OpenAI
import os
import requests

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

prompt = """
a cute cat in garden, pixar, 16:9.
"""

result = client.images.generate(
    model="gpt-4o-image-vip",
    prompt=prompt,
    n=1, # 单次数量
    size="auto", # 1024x1024 (方形), 1536x1024 (3:2 景观), 1024x1536 (2:3 肖像), auto (默认的自动)
    #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):
    image_url = image_data.url # 获取图片 URL
    if image_url: # 检查 URL 是否存在
        try:
            # 下载图片内容
            response = requests.get(image_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

            # 使用找到的唯一 file_path 保存图片到文件
            with open(file_path, "wb") as f:
                f.write(image_bytes)
            print(f"图片已保存至:{file_path}")

        except requests.exceptions.RequestException as e:
            print(f"下载第 {i} 张图片失败:{e}")
        except Exception as e:
            print(f"处理第 {i} 张图片时发生错误:{e}")

    else:
        # 如果 URL 也不存在,则提示
        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 中补充要求。