# 生图配图怎么用 (/docs/models/reference)

配图不是第三种模型。它是同一 `kind=image` 渠道，加上参考图。渠道 ID 与 [生图](/docs/models/images) 相同。

顺序：拿直传凭证 → 把字节 POST 到上传地址 → `POST /v1/images/generate` 带 `fileIds`。

```bash
export BASE=https://www.dexbuddy.app
export DEX_API_KEY='dbh_sk_…'

# 1. 凭证。contentLength 是参考图字节数
curl -sS "$BASE/v1/files" \
  -H "Authorization: Bearer $DEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contentType":"image/png","contentLength":12345}'

# 响应含 id、key、uploadUrl、token

# 2. 直传字节，不经网关
curl -sS "$UPLOAD_URL" \
  -F "token=$TOKEN" \
  -F "key=$KEY" \
  -F "file=@ref.png;type=image/png"

# 3. 生图。fileIds 用第 1 步的 id
curl -sS "$BASE/v1/images/generate" \
  -H "Authorization: Bearer $DEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "image-standard",
    "prompt": "保持构图，改成黄昏",
    "fileIds": ["FILE_ID"]
  }'
```

`POST /v1/files` 免费，不预留积分。成功字段：`id`、`key`、`uploadUrl`、`token`、`expiresAt`。

## 配额错误 [#配额错误]

不要绕过。停在文档给出的码：

| code | 含义 |
|------|------|
| `FILE_QUOTA` | 未过期参考图数量已达上限 |
| `FILE_NOT_USABLE` | 参考图不可用（不存在、已过期或非本人） |

其它错误体是 `{ ok: false, code, error }`。

## 插件侧 [#插件侧]

页面不要 `fetch` 网关。`index.js` 里：

```js
await models.images.generate({
  model: 'image-standard',
  input: {
    prompt,
    input_images: ['/绝对路径/ref.png'],
  },
  outputPath: '/绝对路径/out.png',
});
```

`input_images` 是本机绝对路径，宿主代传。返回 `{ status, output, model }`，`output` 是本地路径。详见 [插件开发 → 模型](/docs/plugins/models)。
