Realm-Generation

PAID
Popularity

6.9 / 10

Latency

204ms

Service Level

92%

Health Check

N/A

Followers: 0
Resources:
Product Website
API Creator:
Rapid account: Realm AI
Realm AI
youpi-inc
Log In to Rate API
Rating: 5 - Votes: 1

README

Example 1: create a yearbook photo for anyone

Required inputs:

  1. a reference image url of the person (example link) who you wanna create the yearbook photo for; (Notes: the better the face is captured in the original image, the better generation results will be)
  2. a prompt text that describe the image to create; E.g., โ€œ@character model student high quality hd, a single yearbook photograph, dark-blue cloudy backdrop, full portrait styleโ€

To generate the desired image, it requires two API calls: 1) create the task 2) fetch the result.

Step 1: calling endpoint /GenerateAvatar to start the generation.

Choose python code as example by replacing the promptPositive field with your own prompt and controlSource pointing to your reference image. Please insert YOUR-OWN-API-KEY as well:

url = "https://realm-generation.p.rapidapi.com/generation"

payload = {
	"promptPositive": "@character model student high quality hd, a single yearbook photograph, dark-blue cloudy backdrop, full portrait style",
	"cfgScale": 7.5,
	"samlplingSteps": 30,
	"controlType": "FACE_FEATURE",
	"controlSource": "https://d28hgpri8am2if.cloudfront.net/book_images/onix/cvr9781982181284/elon-musk-9781982181284_lg.jpg"
}
headers = {
	"content-type": "application/json",
	"X-RapidAPI-Key": "YOUR-OWN-API-KEY",
	"X-RapidAPI-Host": "realm-generation.p.rapidapi.com"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())

This will return the corresponding task id:
{ "promptID": "AOnRQMk1dpkhAsQ4cnZY" }

Step 2: fetch the generated image using returned prompt ID (recommended: every 10 seconds, with timeout 2 minutes)

import requests
import time

url = "https://realm-generation.p.rapidapi.com/generation/AOnRQMk1dpkhAsQ4cnZY"

headers = {
    "X-RapidAPI-Key": "YOUR-OWN-API-KEY",
    "X-RapidAPI-Host": "realm-generation.p.rapidapi.com"
}

start_time = time.time()  # Record the start time
timeout = 120  # Timeout in seconds (2 minutes)

while True:
    response = requests.get(url, headers=headers)
    print(response.json())

    # Check if 2 minutes have passed
    if time.time() - start_time > timeout:
        print("Timeout reached. Exiting.")
        break

    # Wait for 10 seconds before the next check
    time.sleep(10)