加载中
加载中
POST /v1/images/generations — 通过文本创建图像。每返回一张图像需收费。
| 字段 | 说明 |
|---|---|
| model | 来自 的 image 模型的 id |
| prompt | 图像描述,必填,最多 4000 字符 |
| n | 生成图像数量;默认 1。最大值视模型而定:DALL·E 3 返回一张图像 |
| size | 尺寸,例如 1024x1024 |
| quality | 质量(若模型支持) |
| response_format | url or b64_json |
| user | 您的最终用户 ID: |
curl https://llmproxy.org/v1/images/generations \ -H "Authorization: Bearer $LLMPROXY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "google/gemini-3.1-flash-lite-image", "prompt": "A ginger cat in a spacesuit, watercolor", "n": 1}'
响应采用 OpenAI 格式:一个 data 数组,包含 url 链接或在 b64_json 中的 base64,具体取决于 response_format 和模型。图片链接为临时链接:请在本地保存图片。
import base64 resp = client.images.generate( model="google/gemini-3.1-flash-lite-image", prompt="A ginger cat in a spacesuit, watercolor", response_format="b64_json",)with open("cat.png", "wb") as file: file.write(base64.b64decode(resp.data[0].b64_json))
在 fal 和 Replicate 提供的模型中,每张图像的价格以 1 兆像素为准。更大尺寸会在保持纵横比的情况下缩放至 1 MP。
在生成前,会在您的余额中预扣 n 张图像的价格。只有实际返回的图像才会计费:如果只有部分批次返回,未返回的部分不收费。
提示词会被审核。对于图像,任何被标记的类别都会导致拒绝 — 400 content_policy_violation。如果审核暂时不可用,请求可能会被拒绝并返回 503 moderation_unavailable:请几秒后重试。