# Image upscales

Upscale an image to 2K, 4K or 8K.

Source: https://scifig.ai/docs/api/image-upscales

## JSON body

`POST /images/upscales`. Required scope: `figures:generate`.

| Field | Type | Required | Default | Rules |
| --- | --- | --- | --- | --- |
| image | string | yes | — | An image `file_id` |
| scale | string | yes | — | `2k`, `4k` (Starter plan or higher) or `8k` (Plus plan or higher); a credit-pack balance above zero counts as Pro |

| scale | Credits |
| --- | --- |
| 2k | 50 |
| 4k | 100 |
| 8k | 150 |

An image that already reaches the target size returns `400 INVALID_REQUEST` with `details.reason = UPSCALE_ALREADY_AT_TARGET` and charges nothing. Generated illustrations are about 2K, so ask for `4k` or `8k`. A timed-out upscale is refunded and not delivered later. The response is a job; see [Jobs and bounded waiting](/docs/api/jobs) for its fields and statuses. Errors are listed under [Errors](/docs/api/errors).

## cURL

```bash
curl -X POST https://scifig.ai/api/v1/images/upscales \
  -H "Authorization: Bearer $SCIFIG_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Prefer: wait=25" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "<file_id>",
    "scale": "4k"
  }'
```

## JavaScript

```javascript
const response = await fetch('https://scifig.ai/api/v1/images/upscales', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SCIFIG_API_KEY}`,
    'Idempotency-Key': crypto.randomUUID(),
    Prefer: 'wait=25',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "image": "<file_id>",
    "scale": "4k"
  }),
});
const result = await response.json();
console.log(response.status, result);
```

## Python

```python
import os
import uuid

import requests

headers = {
    "Authorization": f"Bearer {os.environ['SCIFIG_API_KEY']}",
    "Idempotency-Key": str(uuid.uuid4()),
    "Prefer": "wait=25",
}
response = requests.post(
    "https://scifig.ai/api/v1/images/upscales",
    headers=headers,
    json={
        "image": "<file_id>",
        "scale": "4k"
    },
    timeout=60,
)
print(response.status_code, response.json())
```
