Closed KINGLIFER closed 2 weeks ago
Also if loras could be added for Fal
I'm sorry but the ideogram API pricing is too much for me to add support. The mandatory $40 initial topup is outrageous and probably explains why no one else supports their API. The here's a quick (completely untested) node which you could use as a starting point:
class IdeogramT2IAPI:
@classmethod
def INPUT_TYPES(cls):
current_dir = os.path.dirname(os.path.abspath(__file__))
api_keys = [f for f in os.listdir(os.path.join(current_dir, "keys")) if f.endswith('.txt')]
return {
"required": {
"positive_prompt": ("STRING", {"multiline": True}),
"negative_prompt": ("STRING", {"multiline": True}),
"model": (["V_1", "V_1_TURBO", "V_2", "V_2_TURBO",],),
"aspect_ratio": (["1:1", "3:4", "4:3", "2:3", "3:2", "3:1", "1:3", "16:9", "9:16", "16:10", "10:16",],),
"magic_prompt": (["AUTO", "ON", "OFF",],),
"v_2_style": (["", "GENERAL", "REALISTIC", "DESIGN", "RENDER_3D", "ANIME",],),
"seed": ("INT", {"default": 1337, "min": 0, "max": 2147483647}),
"api_key": (api_keys,),
},
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "generate_image"
CATEGORY = "ComfyCloudAPIs"
def generate_image(self, positive_prompt, negative_prompt, model, aspect_ratio, magic_prompt, v_2_style, seed, api_key,):
#Set api key
current_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(os.path.join(current_dir, "keys"), api_key), 'r', encoding='utf-8') as file:
key = file.read()
ar_list = {
"1:1": "ASPECT_1_1",
"3:4": "ASPECT_4_3",
"4:3": "ASPECT_4_3",
"2:3": "ASPECT_2_3",
"3:2": "ASPECT_3_2",
"3:1": "ASPECT_3_1",
"1:3": "ASPECT_1_3",
"16:9": "ASPECT_16_9",
"9:16": "ASPECT_9_16",
"16:10": "ASPECT_16_10",
"10:16": "ASPECT_10_16",
}
ar = ar_list.get(aspect_ratio, "ASPECT_1_1")
payload = {
"image_request": {
"prompt": positive_prompt,
"negative_prompt": negative_prompt,
"seed": seed,
"model": model,
"magic_prompt_option": magic_prompt,
"style_type": v_2_style,
"aspect_ratio": ar,
}
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"Api-Key": key,
}
response = requests.post("https://api.ideogram.ai/generate", json=payload, headers=headers)
response = response.json()
image_url = response['data'][0]['url']
#Download the image
response = requests.get(image_url)
image = Image.open(io.BytesIO(response.content))
#make image more comfy
image = np.array(image).astype(np.float32) / 255.0
output_image = torch.from_numpy(image)[None,]
return (output_image,)
Also Fal loras are now supported: The image input is optional, you can add multiple loras by chaining together addlora nodes.
I was not aware of that and I apologize.
Nothing to apologize for, Ideogram support would have been neat, and they don't disclose their credit structure upfront.
(https://ideogram.ai/) Flux is nice but... it seems ideogram is better from the tests I have done.
Would love to use the api in comfyui