Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ The `generate()` function provides a complete end-to-end solution:
```python
# Generate function - handles everything automatically
response = client.v1.ai_image_generator.generate(
image_count=1,
style={"prompt": "A beautiful sunset over mountains"},
name="Sunset Image",
wait_for_completion=True, # Wait for status to be complete/error/canceled
download_outputs=True, # Download files automatically
download_directory="./outputs/" # Where to save files
download_directory="." # Where to save files
)

# You get both the API response AND downloaded file paths
Expand All @@ -129,6 +130,7 @@ The `create()` function provides granular control:
```python
# Create function - only starts the process
create_response = client.v1.ai_image_generator.create(
image_count=1,
style={"prompt": "A beautiful sunset over mountains"},
name="Sunset Image"
)
Expand All @@ -139,7 +141,8 @@ print(f"Started project: {project_id}")

# You must handle the rest:
# 1. Poll for completion. We provide a helper function to handle polling for you
result = client.v1.image_projects.check_status(
result = client.v1.image_projects.check_result(
id=project_id,
wait_for_completion=True,
download_outputs=False,
)
Expand Down
28 changes: 14 additions & 14 deletions magic_hour/resources/v1/ai_face_editor/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ def generate(
assets={"image_file_path": "path/to/face.png"},
style={
"enhance_face": True,
"eye_gaze_horizontal": 0.2,
"eye_gaze_vertical": -0.1,
"eye_open_ratio": 0.8,
"eyebrow_direction": 0.3,
"head_pitch": 0.1,
"eye_gaze_horizontal": 20,
"eye_gaze_vertical": -10,
"eye_open_ratio": 80,
"eyebrow_direction": 30,
"head_pitch": 10,
"head_roll": 0.0,
"head_yaw": -0.2,
"head_yaw": -20,
"lip_open_ratio": 0.0,
"mouth_grim": 0.0,
"mouth_position_horizontal": 0.0,
"mouth_position_vertical": 0.0,
"mouth_pout": 0.0,
"mouth_purse": 0.0,
"mouth_smile": 0.5,
"mouth_smile": 50,
},
name="Face Editor image",
wait_for_completion=True,
Expand Down Expand Up @@ -212,20 +212,20 @@ async def generate(
assets={"image_file_path": "path/to/face.png"},
style={
"enhance_face": True,
"eye_gaze_horizontal": 0.2,
"eye_gaze_vertical": -0.1,
"eye_open_ratio": 0.8,
"eyebrow_direction": 0.3,
"head_pitch": 0.1,
"eye_gaze_horizontal": 20,
"eye_gaze_vertical": -10,
"eye_open_ratio": 80,
"eyebrow_direction": 30,
"head_pitch": 10,
"head_roll": 0.0,
"head_yaw": -0.2,
"head_yaw": -20,
"lip_open_ratio": 0.0,
"mouth_grim": 0.0,
"mouth_position_horizontal": 0.0,
"mouth_position_vertical": 0.0,
"mouth_pout": 0.0,
"mouth_purse": 0.0,
"mouth_smile": 0.5,
"mouth_smile": 50,
},
name="Face Editor image",
wait_for_completion=True,
Expand Down
16 changes: 10 additions & 6 deletions magic_hour/resources/v1/ai_image_editor/README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions magic_hour/resources/v1/ai_image_editor/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def generate(
"""
Generate edited image (alias for create with additional functionality).

Edit image using AI. Each edit costs 5 credits.
Edit images using AI. Credit cost depends on the selected model and resolution.

Args:
name: The name of image. This value is mainly used for your own identification of the image.
Expand Down Expand Up @@ -396,7 +396,7 @@ async def generate(
"""
Generate edited image (alias for create with additional functionality).

Edit image using AI. Each edit costs 5 credits.
Edit images using AI. Credit cost depends on the selected model and resolution.

Args:
name: The name of image. This value is mainly used for your own identification of the image.
Expand Down
16 changes: 9 additions & 7 deletions magic_hour/resources/v1/ai_image_generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ res = client.v1.ai_image_generator.generate(
"tool": "ai-anime-generator",
},
aspect_ratio="1:1",
model="default",
model="z-image-turbo",
name="My Ai Image image",
resolution="1k",
resolution="640px",
wait_for_completion=True,
download_outputs=True,
download_directory="."
Expand All @@ -56,6 +56,8 @@ from os import getenv
client = AsyncClient(token=getenv("API_TOKEN"))
res = await client.v1.ai_image_generator.generate(
image_count=1,
model="z-image-turbo",
resolution="640px",
aspect_ratio="16:9",
style={"prompt": "Cool image", "tool": "ai-anime-generator"},
name="Ai Image image",
Expand Down Expand Up @@ -99,9 +101,9 @@ res = client.v1.ai_image_generator.create(
image_count=1,
style={"prompt": "Cool image", "tool": "ai-anime-generator"},
aspect_ratio="1:1",
model="default",
model="z-image-turbo",
name="My Ai Image image",
resolution="1k",
resolution="640px",
)
```

Expand All @@ -116,9 +118,9 @@ res = await client.v1.ai_image_generator.create(
image_count=1,
style={"prompt": "Cool image", "tool": "ai-anime-generator"},
aspect_ratio="1:1",
model="default",
model="z-image-turbo",
name="My Ai Image image",
resolution="1k",
resolution="640px",
)
```

Expand All @@ -131,5 +133,5 @@ res = await client.v1.ai_image_generator.create(
##### Example

```python
{"credits_charged": 5, "frame_cost": 123, "id": "cuid-example"}
{"credits_charged": 5, "frame_cost": 5, "id": "cuid-example"}
```
4 changes: 2 additions & 2 deletions magic_hour/resources/v1/ai_image_generator/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def generate(
"""
Generate AI images (alias for create with additional functionality).

Create AI images with text prompts. Each image costs 5 credits.
Create AI images with text prompts. Credit cost depends on model, resolution, and image count.

Args:
name: The name of image. This value is mainly used for your own identification of the image.
Expand Down Expand Up @@ -387,7 +387,7 @@ async def generate(
"""
Generate AI images (alias for create with additional functionality).

Create AI images with text prompts. Each image costs 5 credits.
Create AI images with text prompts. Credit cost depends on model, resolution, and image count.

Args:
name: The name of image. This value is mainly used for your own identification of the image.
Expand Down
4 changes: 2 additions & 2 deletions magic_hour/resources/v1/files/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def upload_file(

# Use the uploaded file in other API calls
result = client.v1.ai_image_upscaler.create(
assets={"image_file_path": file_path}, style={"upscale_factor": 2}
assets={"image_file_path": file_path}, scale_factor=2
)
```

Expand Down Expand Up @@ -360,7 +360,7 @@ async def upload_example():

# Use the uploaded file in other API calls
result = await client.v1.ai_image_upscaler.create(
assets={"image_file_path": file_path}, style={"upscale_factor": 2}
assets={"image_file_path": file_path}, scale_factor=2
)


Expand Down
Loading