# 画像の高解像度化

画像を 2K、4K、8K に高解像度化します。

出典：https://scifig.ai/ja/docs/api/image-upscales

## JSON 本文

`POST /images/upscales`。必要なスコープ：`figures:generate`。

| フィールド | 型 | 必須 | 既定値 | 規則 |
| --- | --- | --- | --- | --- |
| image | string | はい | — | 画像の `file_id` |
| scale | string | はい | — | `2k`、`4k`（Starter 以上）、`8k`（Plus 以上）。クレジットパック残高が 0 を超える場合は Pro 相当 |

| scale | クレジット |
| --- | --- |
| 2k | 50 |
| 4k | 100 |
| 8k | 150 |

すでに目標サイズ以上の画像は、`details.reason = UPSCALE_ALREADY_AT_TARGET` 付きの `400 INVALID_REQUEST` を返し、課金しません。生成した科学図表は約 2K のため、`4k` または `8k` を指定してください。タイムアウトした高解像度化は返金され、後から納品されることはありません。レスポンスはジョブです。フィールドとステータスは[ジョブと待機時間の上限](/ja/docs/api/jobs)、エラーは[エラー](/ja/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())
```
