Documentation Index
Fetch the complete documentation index at: https://docs.ruoli.dev/llms.txt
Use this file to discover all available pages before exploring further.
gpt-image-2 是 OpenAI 最新的图像生成模型,最长边支持 3840px。RuoLi 直接透传 OpenAI /v1/images/generations 协议,任何 OpenAI SDK 或兼容客户端都能直接对接。
基础信息
| 项目 | 值 |
|---|
| 端点 | POST https://ruoli.dev/v1/images/generations |
| Token 分组 | codex-team(其它分组报 No available channel) |
| 支持尺寸 | 1K 1024x1024 1536x1024 1024x1536 · 2K 2048x2048 2048x1152 · 4K 3840x2160 2160x3840 |
| 出图时间 | 30 – 90 秒 |
| 定价 | 以定价页为准,按张结算 |
调用示例
curl https://ruoli.dev/v1/images/generations \
-H "Authorization: Bearer sk-你的KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "一只橘猫坐在沙发上",
"size": "3840x2160"
}'
from openai import OpenAI
import base64
client = OpenAI(
api_key="sk-你的KEY",
base_url="https://ruoli.dev/v1",
)
res = client.images.generate(
model="gpt-image-2",
prompt="一只橘猫坐在沙发上",
size="3840x2160",
)
with open("cat.png", "wb") as f:
f.write(base64.b64decode(res.data[0].b64_json))
import OpenAI from "openai";
import fs from "fs";
const client = new OpenAI({
apiKey: "sk-你的KEY",
baseURL: "https://ruoli.dev/v1",
});
const res = await client.images.generate({
model: "gpt-image-2",
prompt: "一只橘猫坐在沙发上",
size: "3840x2160",
});
fs.writeFileSync(
"cat.png",
Buffer.from(res.data[0].b64_json, "base64"),
);
请求参数
| 参数 | 说明 |
|---|
model | 固定 gpt-image-2 |
prompt | 图片描述,中英文均可 |
n | 数量,1 – 10,默认 1 |
size | 见基础信息里的 7 种尺寸 |
quality | standard · hd · medium |
response_format | b64_json(默认)· url。4K 响应 base64 约 8MB,流量敏感场景建议 url |
常见错误
| 报错 | 解决 |
|---|
No available channel | 令牌分组改成 codex-team |
503 ... /images/generations | 改用 /v1/images/generations,不要走 /chat/completions |
Invalid size | 用基础信息里列出的 7 种尺寸 |
504 Gateway Timeout | 客户端超时设到 120 秒以上 |
后台”测试连通”按钮报 503 是正常现象 —— new-api 测试走 /chat/completions,图像模型只认 /images/generations,协议不匹配。真实调用不受影响,忽略即可。