How to Use the OmnigenXL (NSFW & SFW) API for Generating Ultra-Realistic Images

Mar 6, 2024 | Educational

Are you ready to dive into the world of image generation using the OmnigenXL API? In this guide, you’ll learn how to set up your API key, make requests for ultra-realistic image generation, and troubleshoot common issues. Let’s embark on this creative journey!

Step 1: Get Your API Key

The first step in accessing the incredible functionalities of the OmnigenXL API is retrieving your API key from the ModelsLab API. Importantly, this step is completely free!

Step 2: Setting Up Your Request

To generate images using this API, you’ll need to set up your code. Below is an outline of the code you’ll work with:

import requests
import json

url = "https://modelslab.com/api/v6/images/text2img"
payload = json.dumps({
    "key": "your_api_key",
    "model_id": "omnigenxl-nsfw-sfw",
    "prompt": "ultra realistic close up portrait ((beautiful pale cyberpunk female with heavy black eyeliner)), blue eyes, shaved side haircut, hyper detail, cinematic lighting, magic neon, dark red city, Canon EOS R3, nikon, f1.4, ISO 200, 1/160s, 8K, RAW, unedited, symmetrical balance, in-frame, 8K",
    "negative_prompt": "painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime",
    "width": 512,
    "height": 512,
    "samples": 1,
    "num_inference_steps": 30,
    "safety_checker": "no",
    "enhance_prompt": "yes",
    "seed": None,
    "guidance_scale": 7.5,
    "multi_lingual": "no",
    "panorama": "no",
    "self_attention": "no",
    "upscale": "no",
    "embeddings": "embeddings_model_id",
    "lora": "lora_model_id",
    "webhook": None,
    "track_id": None
})

headers = {
    "Content-Type": "application/json"
}

response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

Understanding the Code: The Creative Chef’s Recipe

Imagine you’re a chef in a high-end restaurant, crafting a unique dish (an image). Your ingredients include the API key (your secret recipe), model_id (the type of dish you’re creating), and prompt (the flavor profiles you want to highlight). Just as a chef would carefully measure ingredients to achieve the perfect taste, you must set appropriate parameters such as width and height to produce the picture of your dreams.

  • Payload: Like your mix of ingredients, it contains everything needed to create your image, including both positive and negative prompts to refine the generation process.
  • Headers: Think of them as the cooking utensils that help deliver your creation to the hungry guests (the API).
  • Response: This is the culinary masterpiece you present at the end: the resultant image generated based on your specific instructions.

Step 3: Try the Model for Free

If you want to immediately observe the API in action, head over to Generate Images. You can experience the capabilities of this amazing model without any cost!

Troubleshooting Tips

Sometimes things might not go as planned. Here are some troubleshooting ideas:

  • Error with API Key: Double-check if your API key is correctly copied without any spaces.
  • Invalid Payload: Ensure that the JSON format of your data is correct. A small syntax error can lead to failure.
  • HTTP Errors: If you encounter an HTTP error, verify the URL and ensure that the server is up and running.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

With just a few simple steps and a little bit of creativity, you can unlock the potential of the OmnigenXL API to generate stunning ultra-realistic images. Whether you’re an artist, developer, or simply a curious mind, this tool can lead to extraordinary visual creations.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox