OpenAI Images 兼容
适合只能发送 OpenAI Images 格式的图片客户端。Base URL 为 https://api.hamubox.com/v1,生成端点为 POST /v1/images/generations。使用本站 API Key,并从 /v1/models 选择已开放的 NAI 模型。
请求
章节:请求{ "model": "nai-diffusion-5-full", "prompt": "a blue ceramic cup, soft daylight, illustration", "size": "832x1216", "n": 1, "response_format": "url", "nai": { "uc": "lowres, blurry", "steps": 28, "scale": 5, "seed": 42, "sampler": "k_euler_ancestral" }}| 字段 | 说明 |
|---|---|
model | 必填,NAI 文生图模型 ID;如 nai-diffusion-5-full、nai-diffusion-4-5-full。 |
prompt | 必填,完整主提示词;同时写入角色格式中的主提示词。 |
size | 宽x高,两边为 64 的倍数,总像素不超过 3,145,728。省略或 auto 时使用 nai.width / nai.height,未指定边默认 1024。这里的 auto 不表示智能推断比例。 |
n | 省略或 1。其它值在生成和预扣前拒绝。 |
response_format | url(默认)或 b64_json。 |
nai | 官方 parameters 对象。可设置 uc、steps、scale、sampler、noise_schedule、seed 及角色参数等;显式的 0 和 false 保留。 |
默认 28 步、CFG 5、k_euler_ancestral、karras、PNG。未指定 Seed 时在任务首次接受时生成随机 Seed;网络重试复用任务,不重新随机。size 与 nai.width / nai.height 同时指定时必须一致。nai.n_samples 也只能为 1。
角色提示词可放在 nai.v4_prompt.caption.char_captions 与 nai.v4_negative_prompt.caption.char_captions,格式见角色参数。prompt 和 nai.uc 决定对应的主提示词,角色内容保留。
这里仅提供文生图兼容,不映射 OpenAI 的 quality、style 等参数。图生图、遮罩、官方 multipart 缓存和生成过程流请使用原生接口或任务接口。V5 的氛围与精准参考限制仍然生效。
返回与恢复
章节:返回与恢复{ "created": 1790000000, "data": [{ "url": "https://img.hamubox.com/file/novelai-task-result/image/example.png" }]}选择 b64_json 时每项改为 {"b64_json":"..."},内容是原图片字节的 Base64,保留 PNG 提示词元数据;不会把 Data URL 放进 url 字段。响应在结果保存完成后返回,使用与 NAI 工作台相同的任务、预扣、结算和资产保存流程。
同步等待最多 10 分钟;客户端断开不会取消后台任务。保存 X-NovelAI-Task-Id,通过 GET /v1/novelai/tasks/{task_id} 恢复。推荐每次用户生成都提供新的 Idempotency-Key,网络重试保留同一个值和请求,详见幂等提交。下载结果 URL 时不要携带本站 Key。
