> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memorylake.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Images

> 用 OpenAI 图像模型生成图片

```
POST /openapi/memorylake/router/openai/v1/images/generations
```

OpenAI Images。用图像模型（例如 `gpt-image-1`）根据文本提示词生成图片。下面未列出的参数会原样传给模型。

### 请求头

**x-memorylake-api-key** `string`

使用自带的模型厂商密钥（BYOK）时，在这里放 MemoryLake API Key，模型厂商密钥则放在该厂商原生的鉴权头中。您的模型厂商密钥只会转发给模型厂商，不会被保存。

**traceparent** `string`

W3C 链路上下文。带上后，请求会纳入您的链路，并在 `X-Trace-ID` 中返回同一个 trace id。

### 请求体

**model** `string` *required*

图像模型名称

**prompt** `string` *required*

图片的文字描述

**background** `string`

图片背景。可选值：`transparent`、`opaque`、`auto`。

**n** `integer`

要生成的图片数量

**output\_format** `string`

图片文件格式。可选值：`png`、`jpeg`、`webp`。

**quality** `string`

渲染质量。可选值：`low`、`medium`、`high`、`auto`。

**size** `string`

图片尺寸，例如 `1024x1024`

```bash cURL theme={null}
curl -X POST 'https://app.memorylake.cn/openapi/memorylake/router/openai/v1/images/generations' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gpt-image-1-mini",
    "prompt": "A small red circle on a white background",
    "quality": "low",
    "size": "1024x1024"
  }'
```

### 响应

**created** `integer`

创建时间，Unix 秒级时间戳

**data** `array`

每张图片一项

**Data 对象**

**b64\_json** `string`

图片，base64 编码

**revised\_prompt** `string`

模型改写了您的提示词时实际使用的提示词

**usage** `object`

本次用量

**Usage 对象**

**input\_tokens** `integer`

提示词的 token 数

**output\_tokens** `integer`

生成的图片 token 数

**total\_tokens** `integer`

输入与输出 token 之和

```json Success (200) theme={null}
{
  "created": 1792747467,
  "data": [
    {
      "b64_json": "iVBORw0KGgo…"
    }
  ],
  "usage": {
    "input_tokens": 9,
    "output_tokens": 272,
    "total_tokens": 281
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.