How to Use the AlbedoBase XL 2.0 API for Image Generation

Jan 20, 2024 | Educational

The AlbedoBase XL 2.0 API offers a powerful way to create ultra-realistic images based on text prompts. Whether you’re a developer or a curious enthusiast, this guide provides a user-friendly approach to getting started with the API. Let’s dive in!

Step 1: Obtain Your API Key

To start using the AlbedoBase XL 2.0 API, you first need an API key. Here’s how to get it:

  • Visit the ModelsLab API.
  • Sign up and acquire your API key. No payment is necessary!

Once you have your API key, replace it in the code provided in the following sections.

Step 2: Set Up Your Coding Environment

You can implement the API in various programming languages like PHP, Node.js, or Java. For more code examples, check the documentation here: View docs.

Step 3: Make an API Call

Now that you have your API key, let’s write some code to make an API call. Here’s a Python example of how to do this:

import requests
import json

url = "https://modelslab.com/api/v6/images/text2img"
payload = json.dumps({
    "key": "your_api_key",
    "model_id": "albedobase-xl-20",
    "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, 1160s, 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: An Analogy

Imagine you’re writing a letter to a friend (the API call). At the start, you need to address your friend correctly (the URL), and in the letter, you include your special secret (API key) alongside some details about what you want (prompt). You also include things you do NOT want in the letter (negative_prompt). You finalize the letter with additional details like the size of the paper (width and height) and how detailed you want the reply to be (num_inference_steps). Once you send this letter (make the API call), your friend replies with the picture you’ve asked (the response).

Troubleshooting Tips

If you encounter any issues while using the API, consider the following troubleshooting ideas:

  • Ensure your API key is correctly entered.
  • Verify the model ID is correct; it should be set to “albedobase-xl-20”.
  • Check for any syntax errors in your code.
  • If the API doesn’t respond as expected, confirm that the URL is correct: “https://modelslab.com/api/v6/images/text2img”.

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

Step 4: Additional Resources

To enhance your experience, you can also explore:

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