Whitepaper
Docs
Sign In
Tool
Tool
v0.1
Uncensored FLUX.1 Image Gen
Tool ID
uncensored_flux_image_gen
Creator
@antonymajar
Downloads
366+
Generate uncensored images using flux.1 with novita.ai
Get
README
No README available
Tool Code
Show
""" title: Uncensored FLUX.1 Image Gen author: antonymajar version: 0.1 license: MIT description: Generate uncensored images using flux.1 with novita.ai # Instructions Import the tool Get an api key from novita.ai they will give you a free credit voucher ( use my affiliate link if you'd like to support me :) https://novita.ai/?ref=oty4ndc&utm_source=affiliate ) Set the api key by clicking the tool settings in your workspace """ import os import random import requests from typing import Literal from pydantic import BaseModel, Field class Tools: class Valves(BaseModel): """ Pydantic model for storing API configuration. """ NOVITA_API_KEY: str = Field( default=os.getenv("NOVITA_API_KEY", ""), description="Your API Key for Novita.ai", ) NOVITA_API_BASE_URL: str = Field( default=os.getenv("NOVITA_API_BASE_URL", "https://api.novita.ai"), description="Base URL for the Novita API", ) def __init__(self): self.valves = self.Valves() async def create_flux_schnell_image( self, prompt: str, image_format: str, steps: int = 4, __event_emitter__=None, ) -> str: """ This Tool creates images using the FLUX.1 Schnell model via Novita.ai API. Optimized for fast generation with good quality. :param prompt: The prompt to generate the image :param image_format: Either 'default' for square image, 'landscape' for landscape format, or 'portrait' for portrait format :param steps: Number of denoising steps (1-100, recommended 4-8 for speed) """ try: # Show initial status await __event_emitter__( { "type": "status", "data": { "description": "Creating image with FLUX.1 Schnell...", "done": False, }, } ) # Get dimensions based on format width, height = FORMATS[image_format] # Generate random seed seed = random.randint(0, 4294967295) # Prepare request headers = { "Authorization": f"Bearer {self.valves.NOVITA_API_KEY}", "Content-Type": "application/json", } payload = { "prompt": prompt, "width": width, "height": height, "seed": seed, "steps": steps, "image_num": 1, "response_image_type": "png", } # Make the request response = requests.post( f"{self.valves.NOVITA_API_BASE_URL}/v3beta/flux-1-schnell", headers=headers, json=payload, ) response.raise_for_status() result = response.json() if not result.get("images"): raise Exception("No images generated") image_url = result["images"][0]["image_url"] print(f"FLUX.1 Schnell image URL: {image_url}") # Update status to complete await __event_emitter__( { "type": "status", "data": { "description": "Image Generated Successfully", "done": True, }, } ) # Display the image await __event_emitter__( { "type": "message", "data": {"content": f" \n"}, } ) # Show the prompt used await __event_emitter__( { "type": "message", "data": {"content": f"Prompt: {prompt} \n"}, } ) return f"Only tell the user that the image was successfully generated with the format '{image_format}'. Do not show any links." except Exception as e: # Handle errors await __event_emitter__( { "type": "status", "data": {"description": f"An error occurred: {e}", "done": True}, } ) return f"Tell the user that an error occurred and the image generation was not successful. Reason: {e}" # Image format dimensions FORMATS = { "default": (1024, 1024), "square": (1024, 1024), "landscape": (768, 512), "landscape_large": (1024, 512), "portrait": (512, 768), "portrait_large": (512, 1024), }