# 生成图片

根据文字描述生成图片。计费方式：按生成张数 × 单价（CNY）扣费。
成功后返回图片 URL 列表。

## POST /v1/images/generations

> Generate images

Generate images from text descriptions. Billing: charged per generated image x unit price (CNY).
Returns a list of image URLs on success.

### Authentication

`Authorization: Bearer tr-xxx`

### Request Body

Content-Type: `application/json`

- **model** `string` **(required)**  
  Image model ID. Filter by `type: image` via `GET /v1/models`
- **prompt** `string` **(required)**  
  Image description prompt
- **n** `integer` (default: `1`)  
  Number of images to generate, defaults to 1
- **size** `string`  
  Image dimensions in `widthxheight` format
- **response_format** ``url` | `b64_json``  
  Return style. `url` returns a download link; `b64_json` returns
- **output_format** ``png` | `jpeg``  
  Output file format. Seedream 5.0 Pro/Lite (including the 5.0 alias) support png/jpeg. Seedream 4.5/4.0 have fixed JPEG output and reject this parameter; omit it. On 5.0 Pro this only controls the base layer; layers stay PNG.

### Response

- **created** `integer`  
  Creation time (Unix timestamp in seconds)
- **data** `object[]`  
  List of generated images
- **data[].url** `string`  
  Image access URL
- **data[].b64_json** `string`  
  Base64 image payload when `response_format=b64_json`
- **usage** `object`  
  Token usage (returned by token-billed models such as `gpt-image-2`)
- **usage.input_tokens** `integer`  
  Input tokens (text + reference images)
- **usage.output_tokens** `integer`  
  Output tokens (generated image)
- **usage.total_tokens** `integer`  
  

### Error Codes

- `400`: 
- `401`: 
- `402`: 
- `429`: 
- `502`:
