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
8 changes: 5 additions & 3 deletions comfy_api_nodes/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from enum import Enum
from typing import Any, Dict, List, Optional

from pydantic import AnyUrl, BaseModel, Field, confloat, conint
from pydantic import AnyUrl, BaseModel, Field, confloat, conint, ConfigDict

class Customer(BaseModel):
createdAt: Optional[datetime] = Field(
Expand Down Expand Up @@ -301,7 +301,8 @@ class Quality(str, Enum):


class OpenAIImageEditRequest(BaseModel):
background: Optional[str] = Field(
model_config = ConfigDict(use_enum_values=True)
background: Optional[Background] = Field(
None, description='Background transparency', examples=['opaque']
)
model: str = Field(
Expand All @@ -324,7 +325,7 @@ class OpenAIImageEditRequest(BaseModel):
description='A text description of the desired edit',
examples=['Give the rocketship rainbow coloring'],
)
quality: Optional[str] = Field(
quality: Optional[Quality] = Field(
None, description='The quality of the edited image', examples=['low']
)
size: Optional[str] = Field(
Expand All @@ -335,6 +336,7 @@ class OpenAIImageEditRequest(BaseModel):
description='A unique identifier for end-user monitoring',
examples=['user-1234'],
)



class Quality1(str, Enum):
Expand Down
10 changes: 9 additions & 1 deletion comfy_api_nodes/nodes_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def api_call(self, prompt, seed=0, image=None, mask=None, n=1, size="1024x1024",
n=n,
size=size,
seed=seed,
moderation='low',
),
files={
"image": img_binary,
Expand Down Expand Up @@ -262,6 +263,7 @@ def api_call(self, prompt, seed=0, style="natural", quality="standard", size="10
size=size,
style=style,
seed=seed,
moderation='low',
),
auth_token=auth_token
)
Expand Down Expand Up @@ -304,6 +306,11 @@ def INPUT_TYPES(cls) -> InputTypeDict:
"options": ["low","medium","high"],
"default": "low",
"tooltip": "Image quality, affects cost and generation time.",
}),
"moderation": (IO.COMBO, {
"options": ["low","auto"],
"default": "low",
"tooltip": "Content moderation settings",
}),
"background": (IO.COMBO, {
"options": ["opaque","transparent"],
Expand Down Expand Up @@ -343,7 +350,7 @@ def INPUT_TYPES(cls) -> InputTypeDict:
DESCRIPTION = cleandoc(__doc__ or "")
API_NODE = True

def api_call(self, prompt, seed=0, quality="low", background="opaque", image=None, mask=None, n=1, size="1024x1024", auth_token=None):
def api_call(self, prompt, seed=0, quality="low", moderation="low", background="opaque", image=None, mask=None, n=1, size="1024x1024", auth_token=None):
model = "gpt-image-1"
path = "/proxy/openai/images/generations"
request_class = OpenAIImageGenerationRequest
Expand Down Expand Up @@ -411,6 +418,7 @@ def api_call(self, prompt, seed=0, quality="low", background="opaque", image=Non
model=model,
prompt=prompt,
quality=quality,
moderation=moderation,
background=background,
n=n,
seed=seed,
Expand Down