| import httpx | |
| class FalAPI: | |
| headers = { | |
| 'accept': '*/*', | |
| 'accept-language': 'en-US,en;q=0.9,ja;q=0.8', | |
| 'content-type': 'application/json', | |
| 'origin': 'https://fal-image-generator.vercel.app', | |
| 'priority': 'u=1, i', | |
| 'referer': 'https://fal-image-generator.vercel.app/', | |
| 'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"', | |
| 'sec-ch-ua-mobile': '?0', | |
| 'sec-ch-ua-platform': '"macOS"', | |
| 'sec-fetch-dest': 'empty', | |
| 'sec-fetch-mode': 'cors', | |
| 'sec-fetch-site': 'same-origin', | |
| 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36', | |
| } | |
| def __init__(self): | |
| self.name = "FalAPI" | |
| self.url = "https://fal-image-generator.vercel.app/api/generate-images" | |
| def get_model_list(self): | |
| models = [ | |
| "fal-ai/fast-sdxl", | |
| "fal-ai/flux/dev" | |
| "fal-ai/flux-pro/v1.1-ultra" | |
| "fal-ai/ideogram/v2" | |
| "fal-ai/recraft-v3" | |
| "fal-ai/hyper-sdxl" | |
| ] | |
| return models | |
| async def generate(self, json_data): | |
| json_data.update({'provider': 'fal'}) | |
| async with httpx.AsyncClient() as client: | |
| response = await client.post(self.url, json=json_data) | |
| if response.status_code == 200: | |
| return response.json() | |
| else: | |
| raise Exception(f"Error: {response.status_code} - {response.text}") |