Imagen 4 API: AI 图像生成

通过 Muapi REST API 使用 Imagen 4生成图像。按次生成付费,无需订阅。

交互式模型控制

Google Imagen 4 是 DeepMind 推出的最新文生图 AI 模型,旨在生成细节清晰、文字渲染准确的惊艳逼真图像。它支持最高 2K 的高分辨率输出,可在几秒内生成视觉内容,并嵌入 SynthID 水印以确保真实性。

Imagen 4 API 文档

端点

POST https://api.muapi.ai/api/v1/google-imagen4

使用 Muapi API 密钥在 x-api-key 请求头中提交任务,然后轮询 https://api.muapi.ai/api/v1/predictions/{request_id}/result 直到状态变为 completed。

参数

名称类型必填描述
promptstring是描述图像的文本提示词, what you want the final edited image to look like.
aspect_ratiostring否输出图像的画面比例。选项: 16:9, 9:16, 1:1, 4:3, 3:4默认值: "1:1"
num_imagesint否单次请求生成的图像数量。每张图像单独计费。默认值: 1

cURL 示例

REQUEST_ID=$(curl -s -X POST https://api.muapi.ai/api/v1/google-imagen4 \
  -H "x-api-key: $MUAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"<prompt>"}' | jq -r .request_id)

curl -s https://api.muapi.ai/api/v1/predictions/$REQUEST_ID/result -H "x-api-key: $MUAPI_API_KEY"

Python 示例

import os, time, requests

API = "https://api.muapi.ai/api/v1"
headers = {"x-api-key": os.environ["MUAPI_API_KEY"]}

r = requests.post(f"{API}/google-imagen4", headers=headers, json={"prompt":"<prompt>"})
request_id = r.json()["request_id"]

while True:
    res = requests.get(f"{API}/predictions/{request_id}/result", headers=headers).json()
    if res["status"] == "completed":
        print(res["outputs"]); break
    if res["status"] == "failed":
        raise RuntimeError(res.get("error"))
    time.sleep(3)

完整文档及 Agent/MCP 集成: llms.txt. 在此获取 API 密钥: muapi.ai/access-keys.