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

# Image-to-image

> Upload one normalized reference image and use it in a managed image turn.

# Image-to-image

## What this lets you do

Transform one reference image through a durable managed turn.

## What you need

* A supported PNG, JPEG, or WebP file named `reference.png`
* A server-side DreamLayer test or live key
* One available live credit when using a live key
* `curl` and `jq`

## Steps

### 1. Upload one input

```bash theme={null}
UPLOAD_RESPONSE=$(curl --silent --show-error https://api.dreamlayer.io/v1/input-assets \
  -H "Authorization: Bearer $DREAMLAYER_API_KEY" \
  -F "file=@reference.png")
INPUT_ASSET_ID=$(printf '%s' "$UPLOAD_RESPONSE" | jq -r '.input_asset_id')
export INPUT_ASSET_ID
```

The service accepts supported PNG, JPEG, or WebP input within the published byte, dimension, and pixel limits. It decodes, strips metadata, and stores a normalized owner-scoped PNG.

### 2. Save the returned `input_asset_id`

The commands above store the opaque `input_asset_id` in `INPUT_ASSET_ID`. Store it as application state and do not infer storage paths from it.

### 3. Execute

```bash theme={null}
curl --no-buffer https://api.dreamlayer.io/v1/execute \
  -H "Authorization: Bearer $DREAMLAYER_API_KEY" \
  -H "DreamLayer-Version: 1" \
  -H "Idempotency-Key: greenhouse-edit-001" \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d "{\"prompt\":\"Keep the structure and make the light warmer\",\"input_asset_id\":\"$INPUT_ASSET_ID\",\"aspect_ratio\":\"1:1\",\"max_credits\":1}"
```

V1 accepts one reference image. Unsupported, expired, or cross-account asset IDs fail closed. One completed image-to-image operation uses one live credit.

## Confirm it worked

The stream emits one normalized PNG asset and ends with `done` status `completed`.

## Common errors

* `413`: resize or recompress an input outside the published limits.
* `404`: upload a current asset owned by the authenticated account.
* `422`: send exactly one supported reference image in V1.

## Troubleshooting

Upload the input again if it expired. Do not reuse an asset ID from another account or ask the API to reveal its internal storage path.

## Next steps

* [Understand input and result assets](/agent-api/assets)
* [Resume job events](/agent-api/jobs-and-events)
