1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# v1.ai_image_upscaler
## Module Functions
### AI Image Upscaler <a name="create"></a>
Upscale your image using AI. Each 2x upscale costs 50 credits, and 4x upscale costs 200 credits.
**API Endpoint**: `POST /v1/ai-image-upscaler`
#### Parameters
| Parameter | Required | Description | Example |
| -------------------- | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `assets` | ✓ | Provide the assets for upscaling | `V1AiImageUpscalerCreateBodyAssets {image_file_path: "api-assets/id/1234.png".to_string()}` |
| `└─ image_file_path` | ✓ | The image to upscale. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. . The maximum input image size is 4096x4096px. | `"api-assets/id/1234.png".to_string()` |
| `scale_factor` | ✓ | How much to scale the image. Must be either 2 or 4. Note: 4x upscale is only available on Creator, Pro, or Business tier. | `2.0` |
| `style` | ✓ | Style settings for the upscale. Use `mode` to select between `"pro"` (faster, no enhancement required) and `"creative"` (defaults to `"Balanced"` enhancement). Defaults to `"creative"`. | `V1AiImageUpscalerCreateBodyStyle {mode: Some(V1AiImageUpscalerCreateBodyStyleModeEnum::Creative), ..Default::default()}` |
| `└─ enhancement` | ✗ | | `V1AiImageUpscalerCreateBodyStyleEnhancementEnum::Balanced` |
| `└─ mode` | ✗ | The upscaling mode. `"pro"` is faster and does not require `enhancement`. `"creative"` requires `enhancement`. Defaults to `"creative"`. | `V1AiImageUpscalerCreateBodyStyleModeEnum::Creative` |
| `└─ prompt` | ✗ | A prompt to guide the final image. This value is ignored if `enhancement` is not Creative | `"string".to_string()` |
| `name` | ✗ | Give your image a custom name for easy identification. | `"My Image Upscaler image".to_string()` |
#### Example Snippet
```rust
let client = magic_hour::Client::default()
.with_bearer_auth(&std::env::var("API_TOKEN").unwrap());
let res = client
.v1()
.ai_image_upscaler()
.create(magic_hour::resources::v1::ai_image_upscaler::CreateRequest {
assets: magic_hour::models::V1AiImageUpscalerCreateBodyAssets {
image_file_path: "api-assets/id/1234.png".to_string(),
},
name: Some("My Image Upscaler image".to_string()),
scale_factor: 2.0,
style: magic_hour::models::V1AiImageUpscalerCreateBodyStyle {
mode: Some(
magic_hour::models::V1AiImageUpscalerCreateBodyStyleModeEnum::Creative,
),
..Default::default()
},
})
.await;
```
#### Response
##### Type
[V1AiImageUpscalerCreateResponse](/src/models/v1_ai_image_upscaler_create_response.rs)
##### Example
```rust
V1AiImageUpscalerCreateResponse {credits_charged: 50, frame_cost: 50, id: "cuid-example".to_string()}
```