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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# v1.ai_face_editor
## Module Functions
### AI Face Editor <a name="create"></a>
Edit facial features of an image using AI. Each edit costs 1 frame. The height/width of the output image depends on your subscription. Please refer to our [pricing](https://magichour.ai/pricing) page for more details
**API Endpoint**: `POST /v1/ai-face-editor`
#### Parameters
| Parameter | Required | Description | Example |
| ------------------------------ | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `assets` | ✓ | Provide the assets for face editor | `V1AiFaceEditorCreateBodyAssets {image_file_path: "api-assets/id/1234.png".to_string()}` |
| `└─ image_file_path` | ✓ | This is the image whose face will be edited. This value is either - a direct URL to the file. The URL path must end in a supported file extension. - `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. | `"api-assets/id/1234.png".to_string()` |
| `style` | ✓ | Face editing parameters | `V1AiFaceEditorCreateBodyStyle {enhance_face: Some(false), eye_gaze_horizontal: Some(0.0), eye_gaze_vertical: Some(0.0), eye_open_ratio: Some(0.0), eyebrow_direction: Some(0.0), head_pitch: Some(0.0), head_roll: Some(0.0), head_yaw: Some(0.0), lip_open_ratio: Some(0.0), mouth_grim: Some(0.0), mouth_position_horizontal: Some(0.0), mouth_position_vertical: Some(0.0), mouth_pout: Some(0.0), mouth_purse: Some(0.0), mouth_smile: Some(0.0)}` |
| `└─ enhance_face` | ✗ | Enhance face features | `false` |
| `└─ eye_gaze_horizontal` | ✗ | Horizontal eye gaze (-100 to 100), in increments of 5 | `0.0` |
| `└─ eye_gaze_vertical` | ✗ | Vertical eye gaze (-100 to 100), in increments of 5 | `0.0` |
| `└─ eye_open_ratio` | ✗ | Eye open ratio (-100 to 100), in increments of 5 | `0.0` |
| `└─ eyebrow_direction` | ✗ | Eyebrow direction (-100 to 100), in increments of 5 | `0.0` |
| `└─ head_pitch` | ✗ | Head pitch (-100 to 100), in increments of 5 | `0.0` |
| `└─ head_roll` | ✗ | Head roll (-100 to 100), in increments of 5 | `0.0` |
| `└─ head_yaw` | ✗ | Head yaw (-100 to 100), in increments of 5 | `0.0` |
| `└─ lip_open_ratio` | ✗ | Lip open ratio (-100 to 100), in increments of 5 | `0.0` |
| `└─ mouth_grim` | ✗ | Mouth grim (-100 to 100), in increments of 5 | `0.0` |
| `└─ mouth_position_horizontal` | ✗ | Horizontal mouth position (-100 to 100), in increments of 5 | `0.0` |
| `└─ mouth_position_vertical` | ✗ | Vertical mouth position (-100 to 100), in increments of 5 | `0.0` |
| `└─ mouth_pout` | ✗ | Mouth pout (-100 to 100), in increments of 5 | `0.0` |
| `└─ mouth_purse` | ✗ | Mouth purse (-100 to 100), in increments of 5 | `0.0` |
| `└─ mouth_smile` | ✗ | Mouth smile (-100 to 100), in increments of 5 | `0.0` |
| `name` | ✗ | Give your image a custom name for easy identification. | `"My Face Editor 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_face_editor()
.create(magic_hour::resources::v1::ai_face_editor::CreateRequest {
assets: magic_hour::models::V1AiFaceEditorCreateBodyAssets {
image_file_path: "api-assets/id/1234.png".to_string(),
},
name: Some("My Face Editor image".to_string()),
style: magic_hour::models::V1AiFaceEditorCreateBodyStyle {
enhance_face: Some(false),
eye_gaze_horizontal: Some(0.0),
eye_gaze_vertical: Some(0.0),
eye_open_ratio: Some(0.0),
eyebrow_direction: Some(0.0),
head_pitch: Some(0.0),
head_roll: Some(0.0),
head_yaw: Some(0.0),
lip_open_ratio: Some(0.0),
mouth_grim: Some(0.0),
mouth_position_horizontal: Some(0.0),
mouth_position_vertical: Some(0.0),
mouth_pout: Some(0.0),
mouth_purse: Some(0.0),
mouth_smile: Some(0.0),
},
})
.await;
```
#### Response
##### Type
[V1AiFaceEditorCreateResponse](/src/models/v1_ai_face_editor_create_response.rs)
##### Example
```rust
V1AiFaceEditorCreateResponse {credits_charged: 1, frame_cost: 123, id: "cuid-example".to_string()}
```