### POST /api/examples - Multiple Reference Images Source: https://context7.com/retro-diffusion/api-examples/llms.txt This endpoint allows for image generation using multiple reference images (up to 9) to guide the output. Specialized prompt styles like 'rd_pro__fantasy', 'rd_pro__isometric', and 'rd_pro__dungeon_map' can be used for different generation types. ```APIDOC ## POST /api/examples ### Description Generates an image using multiple reference images and a text prompt. Supports various specialized prompt styles for different output types. ### Method POST ### Endpoint /api/examples ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **width** (integer) - Required - The width of the generated image. - **height** (integer) - Required - The height of the generated image. - **prompt** (string) - Required - The text description for the image generation. - **prompt_style** (string) - Required - The style to apply to the generation (e.g., 'rd_pro__fantasy', 'rd_pro__isometric'). - **num_images** (integer) - Optional - The number of images to generate. - **reference_images** (array of strings) - Optional - A list of base64 encoded reference images. - **seed** (integer) - Optional - The seed for reproducibility. ### Request Example ```json { "width": 256, "height": 256, "prompt": "warrior character facing forward, detailed armor and weapon", "prompt_style": "rd_pro__fantasy", "num_images": 1, "reference_images": [ "base64_encoded_image1", "base64_encoded_image2", "base64_encoded_image3" ], "seed": 100 } ``` ### Response #### Success Response (200) - **base64_images** (array of strings) - A list of base64 encoded generated images. #### Response Example ```json { "base64_images": [ "base64_encoded_generated_image" ], "credit_cost": 1, "remaining_credits": 99 } ``` ``` -------------------------------- ### Generate Tileset Objects and Scene Assets using Python Source: https://context7.com/retro-diffusion/api-examples/llms.txt This snippet demonstrates generating small decorative tile objects (16x16 to 96x96) and larger scene assets for map decoration (64x64 to 384x384). It includes examples like trees, rocks, and furniture. Requires the 'requests' and 'base64' libraries. ```python import requests import base64 url = "https://api.retrodiffusion.ai/v1/inferences" headers = { "X-RD-Token": "rdpk-your-api-key-here" } # Small tile objects (items that fit on tiles) tile_objects = [ "wooden barrel with metal bands", "treasure chest with golden lock", "stone pillar with carved runes", "campfire with glowing embers" ] for obj in tile_objects: payload = { "width": 32, "height": 32, "prompt": obj, "num_images": 1, "prompt_style": "rd_tile__tile_object" } response = requests.post(url, headers=headers, json=payload) if response.status_code == 200: data = response.json() filename = f"object_{obj.split()[0]}.png" with open(filename, "wb") as f: f.write(base64.b64decode(data['base64_images'][0])) # Large scene objects scene_payload = { "width": 256, "height": 256, "prompt": "ancient oak tree with thick trunk and full canopy", "num_images": 1, "prompt_style": "rd_tile__scene_object", "remove_bg": True # Transparent background for easy placement } response_scene = requests.post(url, headers=headers, json=scene_payload) if response_scene.status_code == 200: data_scene = response_scene.json() with open("tree_large.png", "wb") as f: f.write(base64.b64decode(data_scene['base64_images'][0])) print("Large scene object created with transparent background") ``` -------------------------------- ### POST /v1/inferences (Animation with Input Image Reference) Source: https://context7.com/retro-diffusion/api-examples/llms.txt Generates animations based on a reference image to maintain character consistency. The input image guides the animation style and appearance. ```APIDOC ## POST /v1/inferences (Animation with Input Image Reference) ### Description Generate animations based on a reference image to maintain character consistency. The input image guides the animation style and appearance. ### Method POST ### Endpoint /v1/inferences ### Parameters #### Header Parameters - **X-RD-Token** (string) - Required - Your API key. #### Request Body - **prompt** (string) - Required - The text prompt describing the desired animation. - **width** (integer) - Optional - The width of the animation in pixels. Defaults to 48. - **height** (integer) - Optional - The height of the animation in pixels. Defaults to 48. - **num_images** (integer) - Optional - The number of images to generate. Defaults to 1. - **seed** (integer) - Optional - The seed for random number generation. - **prompt_style** (string) - Required - The style of animation. Example: `animation__four_angle_walking`. - **return_spritesheet** (boolean) - Optional - Whether to return the animation as a spritesheet. Defaults to `false`. - **input_image** (string) - Required - The base64 encoded reference image. ### Request Example ```json { "prompt": "futuristic robot with glowing eyes", "width": 48, "height": 48, "num_images": 1, "seed": 1234, "prompt_style": "animation__four_angle_walking", "return_spritesheet": true, "input_image": "base64_encoded_image_string" } ``` ### Response #### Success Response (200) - **base64_images** (array of strings) - An array containing the base64 encoded generated animation(s). #### Response Example ```json { "base64_images": ["base64_encoded_animation_string"], "credit_cost": 1 } ``` ``` -------------------------------- ### RD_PRO Model with Reference Images using Python Source: https://context7.com/retro-diffusion/api-examples/llms.txt Demonstrates using the RD_PRO model with reference images for enhanced control over generated pixel art. This example includes a helper function to encode local images into base64 format, required for sending as references. Requires 'requests', 'base64', 'PIL', and 'io' libraries. ```python import requests import base64 from PIL import Image from io import BytesIO def encode_image(image_path): with Image.open(image_path) as img: rgb_img = img.convert('RGB') buffer = BytesIO() rgb_img.save(buffer, format='PNG') return base64.b64encode(buffer.getvalue()).decode('utf-8') url = "https://api.retrodiffusion.ai/v1/inferences" headers = { "X-RD-Token": "rdpk-your-api-key-here" } # Example usage (would require actual image paths and payload structure for RD_PRO): # reference_image_1 = encode_image('path/to/your/reference1.png') # reference_image_2 = encode_image('path/to/your/reference2.png') # # payload = { # "prompt": "A futuristic cityscape", # "model_tier": "rd_pro", # "reference_images": [reference_image_1, reference_image_2], # "width": 512, # "height": 512 # } # # response = requests.post(url, headers=headers, json=payload) ``` -------------------------------- ### RD_PRO Model Styles and Reference Images Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Documentation for using the RD_PRO model, including its available styles and how to use reference images. ```APIDOC ## Using RD_PRO Model ### Description The RD_PRO model is the most advanced model supporting various styles and reference images. Styles are applied using the `prompt_style` parameter, and reference images are passed as base64 encoded strings in the `reference_images` parameter. ### Available Styles for RD_PRO - **rd_pro__default**: Clean modern pixel art style with multiple reference image support and detailed prompting. - **rd_pro__painterly**: Brush-like style with minimal outlines, vibrant colors, and detailed textures. - **rd_pro__fantasy**: Bright colors, soft transitions, detailed textures, light dithering, and outlines. - **rd_pro__horror**: Dark, gritty style with chaotic details and harsh shapes/shading. - **rd_pro__scifi**: High contrast with glowing details, clean outlines, and beautiful lighting. - **rd_pro__simple**: Simple pixel art with minimal shading/texturing, strong outlines, and shapes. - **rd_pro__isometric**: Pixel art rotated at a 45-degree angle, with clean lines and shapes. - **rd_pro__topdown**: Pixel art viewed from a 2/3 downward angle, with simple shapes and shading. - **rd_pro__platformer**: Side-scroller style platformer perspective with modern styling and outlines. - **rd_pro__dungeon_map**: Dungeon-crawler style game levels with connected rooms. - **rd_pro__spritesheet**: Collections of assets on a simple background in the same style. - **rd_pro__pixelate**: Converts input images into pixel art. ### Using Reference Images with RD_PRO - You can use up to 9 reference images. - Pass base64 encoded images in the `reference_images` parameter within the request body. ### Request Example with RD_PRO and Reference Image ```json { "width": 256, "height": 256, "prompt": "corgi", "num_images": 1, "prompt_style": "rd_pro__default", "check_cost": false, "reference_images": [ "iVBORw0KGgoAAA..." ] } ``` ``` -------------------------------- ### Bypass Prompt Expansion - Python Source: https://context7.com/retro-diffusion/api-examples/llms.txt Demonstrates how to disable automatic prompt expansion for precise control over the generated output. This is useful for specific use cases like generating game assets where exact prompt adherence is critical. The example also shows how to potentially retrieve images at native resolution by setting `upscale_output_factor` (though not explicitly shown in this snippet, it's a related parameter). ```python import requests import base64 url = "https://api.retrodiffusion.ai/v1/inferences" headers = { "X-RD-Token": "rdpk-your-api-key-here" } # Bypass prompt expansion for exact prompt control precise_payload = { "prompt": "sword, shield, helm, 16x16 grid", "width": 256, "height": 256, "prompt_style": "rd_fast__game_asset", "num_images": 1, "bypass_prompt_expansion": True } response = requests.post(url, headers=headers, json=precise_payload) ``` -------------------------------- ### Full Tileset Generation API Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Generate full tilesets using predefined styles. Supports inspiration images and advanced texture configurations. ```APIDOC ## POST /generate/tileset ### Description Generates full tilesets using specified styles, with options for inspiration images and advanced texture prompts. ### Method POST ### Endpoint /generate/tileset ### Parameters #### Query Parameters - **prompt_style** (string) - Required - The style to use for tileset generation (e.g., `rd_tile__tileset`, `rd_tile__tileset_advanced`). - **width** (integer) - Optional - The width of each tile in pixels. Range: 16-32. Default: 32. - **height** (integer) - Optional - The height of each tile in pixels. Range: 16-32. Default: 32. - **prompt** (string) - Required for `rd_tile__tileset_advanced` - Description for the inside texture. - **extra_prompt** (string) - Required for `rd_tile__tileset_advanced` - Description for the outside texture. - **num_images** (integer) - Optional - The number of tilesets to generate. Default: 1. - **seed** (integer) - Optional - The seed for random generation. - **input_image** (string) - Optional - Base64 encoded image for inspiration (for `rd_tile__tileset`). - **extra_input_image** (string) - Optional - Base64 encoded image for advanced texture reference (for `rd_tile__tileset_advanced`). ### Request Body ```json { "width": 32, "height": 32, "prompt": "grey stones with gravel and dirt", "extra_prompt": "lush green grass", "num_images": 1, "prompt_style": "rd_tile__tileset_advanced", "seed": 123, "input_image": "iVBORw0KGgoAAAANSUhEUgAAAUA... ... ...", "extra_input_image": "iVBORw0KGgoAAAANSUhEUgAAAUA... ... ..." } ``` ### Response #### Success Response (200) - **base64_images** (array[string]) - An array of base64 encoded generated tilesets. #### Response Example ```json { "base64_images": [ "iVBORw0KGgoAAAANSUhEUgAAAUA... ... ..." ] } ``` ``` -------------------------------- ### Generate Image with Multiple Reference Images (Python) Source: https://context7.com/retro-diffusion/api-examples/llms.txt Generates an image using multiple reference images (up to 9) to guide the style and content. Requires image encoding and a POST request to the API. ```python import requests import base64 def encode_image(image_path): with open(image_path, "rb") as f: return base64.b64encode(f.read()).decode('utf-8') url = "https://api.retrodiffusion.ai/v1/inferences" headers = { "X-RD-Token": "rdpk-your-api-key-here" } reference_images = [ encode_image("character_ref1.png"), encode_image("character_ref2.png"), encode_image("style_ref.png") ] payload = { "width": 256, "height": 256, "prompt": "warrior character facing forward, detailed armor and weapon", "prompt_style": "rd_pro__fantasy", "num_images": 1, "reference_images": reference_images, "seed": 100 } response = requests.post(url, headers=headers, json=payload) if response.status_code == 200: data = response.json() with open("warrior_output.png", "wb") as f: f.write(base64.b64decode(data['base64_images'][0])) print(f"Generated with {len(reference_images)} reference images") # Using specialized RD_PRO styles isometric_payload = { "width": 256, "height": 256, "prompt": "fantasy tavern building with wooden sign", "prompt_style": "rd_pro__isometric", "num_images": 1 } dungeon_payload = { "width": 384, "height": 384, "prompt": "ancient dungeon level with treasure chests and monsters", "prompt_style": "rd_pro__dungeon_map", "num_images": 1 } ``` -------------------------------- ### Check Image Generation Cost with Python Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md This example shows how to check the estimated credit cost for an image generation request without actually creating an image. By setting `check_cost` to `true`, the API returns the cost and remaining credits but no image data. Note that `remaining_credits` will always be 0 in this mode. ```python import requests url = "https://api.retrodiffusion.ai/v1/inferences" method = "POST" headers = { "X-RD-Token": "YOUR_API_KEY", } payload = { "width": 256, "height": 256, "prompt": "A really cool corgi", "num_images": 1, "check_cost": true } response = requests.request(method, url, headers=headers, json=payload) print(response.text) ``` -------------------------------- ### RD_FAST Model Style Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Documentation for using the RD_FAST model, which supports a single style at a time via the `prompt_style` parameter. ```APIDOC ## Using RD_FAST Model ### Description The RD_FAST model supports one style at a time, which is specified using the `prompt_style` parameter. ### Request Example with RD_FAST Style ```json { "width": 256, "height": 256, "prompt": "A really cool corgi wearing sunglasses and a party hat", "num_images": 1, "prompt_style": "rd_fast__simple" } ``` ``` -------------------------------- ### Seamless Tiling Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Enable seamless tiling for generated images by setting `tile_x` and `tile_y` to true in your request payload. ```APIDOC ## Using seamless tiling ### Description To generate images that can be seamlessly tiled, include the boolean parameters `tile_x` and `tile_y` set to `true` in your request payload. ### Method POST ### Endpoint `/api/images` (Assumed, as not explicitly stated but implied by payload structure) ### Parameters #### Request Body - **prompt** (string) - Required - The text prompt for image generation. - **width** (integer) - Required - The desired width of the image. - **height** (integer) - Required - The desired height of the image. - **tile_x** (boolean) - Required - Enables horizontal seamless tiling. - **tile_y** (boolean) - Required - Enables vertical seamless tiling. ### Request Example ```json { "prompt": "Stone bricks", "width": 128, "height": 128, "tile_x": true, "tile_y": true } ``` ``` -------------------------------- ### Check Remaining Credits in JSON Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md To check your remaining credits, make a GET request to `/v1/inferences/credits` with your API key in the `X-RD-Token` header. The response contains your current credit balance. ```json { "credits": 999 } ``` -------------------------------- ### Generate Image with RD_PRO and Styles (JSON) Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md This JSON payload illustrates how to generate an image using the advanced RD_PRO model with a specific style applied. It also includes an example of how to pass base64 encoded reference images for style guidance. ```json { "width": 256, "height": 256, "prompt": "corgi", "num_images": 1, "prompt_style": "rd_pro__default", "check_cost": false, "reference_images": [ "iVBORw0KGgoAAA..." ] } ``` -------------------------------- ### Batch Generation with Multiple Styles Source: https://context7.com/retro-diffusion/api-examples/llms.txt Generate multiple variations of the same prompt using different style presets for comparison and selection of the best artistic direction. ```APIDOC ## POST /v1/inferences (Batch Styles) ### Description Generate multiple variations of the same prompt using different style presets for comparison and selection of the best artistic direction. This example iterates through a list of styles and calls the `/v1/inferences` endpoint for each. ### Method POST ### Endpoint https://api.retrodiffusion.ai/v1/inferences ### Parameters #### Headers - **X-RD-Token** (string) - Required - Your API key. #### Request Body (per style) - **prompt** (string) - Required - The text prompt to generate images from. - **width** (integer) - Optional - The width of the generated images. Defaults to 256. - **height** (integer) - Optional - The height of the generated images. Defaults to 256. - **prompt_style** (string) - Required - The specific style preset to use for this generation. - **num_images** (integer) - Optional - The number of images to generate. Defaults to 1. - **seed** (integer) - Optional - The seed for the random number generator, used for reproducible results. ### Request Example (for a single style) ```json { "prompt": "ancient temple ruins in a mystical forest", "width": 256, "height": 256, "prompt_style": "rd_pro__fantasy", "num_images": 1, "seed": 12345 } ``` ### Response (per style) #### Success Response (200) - **base64_images** (array of strings) - An array of base64 encoded image strings. - **credit_cost** (integer) - The number of credits consumed for this generation. #### Response Example ```json { "base64_images": ["...base64_encoded_image_string..."], "credit_cost": 10 } ``` ``` -------------------------------- ### Tile Variation API Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Create variations of an existing tile. Requires an input image and a prompt describing desired changes. ```APIDOC ## POST /generate/tile_variation ### Description Generates variations of a given tile using the `rd_tile__tile_variation` style. ### Method POST ### Endpoint /generate/tile_variation ### Parameters #### Query Parameters - **width** (integer) - Optional - The width of the tile variations in pixels. Range: 16-64. Default: 32. - **height** (integer) - Optional - The height of the tile variations in pixels. Range: 16-64. Default: 32. - **prompt** (string) - Required - Description of the desired changes for the variations. - **num_images** (integer) - Optional - The number of variations to generate. Default: 1. - **prompt_style** (string) - Required - Must be `rd_tile__tile_variation`. - **input_image** (string) - Required - Base64 encoded image of the tile to create variations from. ### Request Body ```json { "width": 32, "height": 32, "prompt": "add moss and cracks", "num_images": 1, "prompt_style": "rd_tile__tile_variation", "input_image": "iVBORw0KGgoAAAANSUhEUgAAAUA... ... ..." } ``` ### Response #### Success Response (200) - **base64_images** (array[string]) - An array of base64 encoded tile variations. #### Response Example ```json { "base64_images": [ "iVBORw0KGgoAAAANSUhEUgAAAUA... ... ..." ] } ``` ``` -------------------------------- ### POST /v1/inferences Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Generate images using the Retro Diffusion API. Requires an API Key and available credits. You can specify dimensions, prompt, and number of images. ```APIDOC ## POST /v1/inferences ### Description This endpoint generates images based on a text prompt. You need to provide an API key and ensure you have sufficient credits. ### Method POST ### Endpoint `https://api.retrodiffusion.ai/v1/inferences` ### Parameters #### Headers - **X-RD-Token** (string) - Required - Your API key. #### Request Body - **width** (integer) - Optional - The width of the generated image. Default range is 64-384. - **height** (integer) - Optional - The height of the generated image. Default range is 64-384. - **prompt** (string) - Required - The text description for the image generation. - **num_images** (integer) - Optional - The number of images to generate. Defaults to 1. - **prompt_style** (string) - Optional - The style to apply to the image generation. See available styles for different models. - **check_cost** (boolean) - Optional - If true, only the credit cost is returned without generating images. Defaults to false. - **reference_images** (array of strings) - Optional - An array of base64 encoded images to use as references (e.g., with RD_PRO model). ### Request Example ```json { "width": 256, "height": 256, "prompt": "A really cool corgi", "num_images": 1 } ``` ### Response #### Success Response (200) - **created_at** (integer) - Timestamp of when the request was created. - **credit_cost** (integer) - The number of credits used for the generation. - **base64_images** (array of strings) - An array of base64 encoded generated images. - **type** (string) - The type of generation, e.g., "txt2img". - **remaining_credits** (integer) - The number of credits remaining after the generation. - **output_images** (array of strings) - Empty if images are generated. - **output_urls** (array of strings) - Empty if images are generated. - **model** (string) - The model used for generation. #### Response Example ```json { "created_at": 1733425519, "credit_cost": 1, "base64_images": ["..."], "type": "txt2img", "remaining_credits": 999 } ``` ``` -------------------------------- ### Tileset Generation API Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md This API allows for the generation of various tileset styles, from simple textures to advanced combinations and scene objects. ```APIDOC ## POST /generate/tileset ### Description Generates tilesets based on the provided prompt and style. ### Method POST ### Endpoint /generate/tileset ### Parameters #### Query Parameters - **prompt** (string) - Required - The description of the tileset to generate. - **width** (integer) - Required - The width of the tile (e.g., 16, 32). - **height** (integer) - Required - The height of the tile (e.g., 16, 32). - **prompt_style** (string) - Required - The tileset style to use (e.g., `rd_tile__tileset`, `rd_tile__tileset_advanced`, `rd_tile__single_tile`, `rd_tile__tile_variation`, `rd_tile__tile_object`, `rd_tile__scene_object`). - **second_prompt** (string) - Optional - A second prompt for advanced tileset generation. - **input_image** (string) - Optional - Base64 encoded RGB image for tile variation or object generation. ### Request Example (Simple Tileset) ```json { "prompt": "forest ground textures", "width": 16, "height": 16, "prompt_style": "rd_tile__tileset" } ``` ### Request Example (Advanced Tileset) ```json { "prompt": "stone path", "second_prompt": "mossy cobblestone", "width": 32, "height": 32, "prompt_style": "rd_tile__tileset_advanced" } ``` ### Request Example (Single Tile) ```json { "prompt": "a weathered wooden door", "width": 64, "height": 64, "prompt_style": "rd_tile__single_tile" } ``` ### Response #### Success Response (200) - **image_data** (string) - Base64 encoded PNG of the generated tileset. #### Response Example ```json { "image_data": "iVBORw0KGgoAAAANSUhEUgAA... ... ..." } ``` ``` -------------------------------- ### Generate Single Tile with Prompt (Python) Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Creates a single tile based on a provided prompt and dimensions. Uses the `rd_tile__single_tile` style. Parameters include `width`, `height`, `prompt`, `num_images`, and `prompt_style`. ```python { "width": 32, "height": 32, "prompt": "volcanic rock with cracks", "num_images": 1, "prompt_style": "rd_tile__single_tile" } ``` -------------------------------- ### Background Removal and Palette Application Source: https://context7.com/retro-diffusion/api-examples/llms.txt Remove backgrounds to create transparent sprites and apply custom color palettes for consistent art style across assets. ```APIDOC ## POST /v1/inferences ### Description Removes backgrounds from generated images to create transparent sprites and optionally applies custom color palettes. ### Method POST ### Endpoint /v1/inferences ### Parameters #### Request Body - **prompt** (string) - Required - A text description of the desired sprite. - **width** (integer) - Required - The width of the generated sprite. - **height** (integer) - Required - The height of the generated sprite. - **prompt_style** (string) - Required - The style of prompt to use (e.g., `rd_fast__portrait`). - **num_images** (integer) - Optional - The number of images to generate. - **remove_bg** (boolean) - Required - Whether to remove the background. - **return_non_bg_removed** (boolean) - Optional - Whether to return the original image along with the background-removed version. ### Request Example ```json { "prompt": "heroic knight character with sword and shield", "width": 128, "height": 128, "prompt_style": "rd_fast__portrait", "num_images": 1, "remove_bg": true, "return_non_bg_removed": true } ``` ### Response #### Success Response (200) - **base64_images** (array[string]) - An array of base64 encoded images. If `return_non_bg_removed` is true, the first image is transparent and the second is the original. #### Response Example ```json { "base64_images": [ "/9j/4AAQSkZJRgABAQEA...", "/9j/4AAQSkZJRgABAQEA..." ] } ``` ``` -------------------------------- ### Single Tile Generation API Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Generate individual tiles using the `rd_tile__single_tile` style. Specify dimensions and a descriptive prompt. ```APIDOC ## POST /generate/single_tile ### Description Generates a single tile image using the `rd_tile__single_tile` style. ### Method POST ### Endpoint /generate/single_tile ### Parameters #### Query Parameters - **width** (integer) - Optional - The width of the tile in pixels. Range: 16-64. Default: 32. - **height** (integer) - Optional - The height of the tile in pixels. Range: 16-64. Default: 32. - **prompt** (string) - Required - Description of the tile's appearance. - **num_images** (integer) - Optional - The number of single tiles to generate. Default: 1. - **prompt_style** (string) - Required - Must be `rd_tile__single_tile`. ### Request Body ```json { "width": 32, "height": 32, "prompt": "volcanic rock with cracks", "num_images": 1, "prompt_style": "rd_tile__single_tile" } ``` ### Response #### Success Response (200) - **base64_images** (array[string]) - An array containing the base64 encoded generated tile. #### Response Example ```json { "base64_images": [ "iVBORw0KGgoAAAANSUhEUgAAAUA... ... ..." ] } ``` ``` -------------------------------- ### Enable Seamless Tiling in Python Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Add `tile_x` and `tile_y` parameters as booleans to your payload to enable seamless tiling for generated images. This is useful for creating repeating patterns or textures. ```python payload = { "prompt": "Stone bricks", "width": 128, "height": 128, "tile_x": true, "tile_y": true } ``` -------------------------------- ### POST /v1/inferences - Generate Sprite Animation Source: https://context7.com/retro-diffusion/api-examples/llms.txt Generates sprite sheet animations, including walking, idle, and other custom animations with transparent backgrounds. Supports various animation styles. ```APIDOC ## POST /v1/inferences ### Description Generates sprite animations in various formats, such as walking, idle, and rotational, returned as a spritesheet. ### Method POST ### Endpoint /v1/inferences ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **prompt** (string) - Required - The text prompt describing the character or object. - **width** (integer) - Required - The width of each sprite frame. - **height** (integer) - Required - The height of each sprite frame. - **num_images** (integer) - Optional - The number of animations to generate (usually 1 for a spritesheet). - **seed** (integer) - Optional - The seed for reproducibility. - **prompt_style** (string) - Required - The animation style (e.g., 'animation__four_angle_walking', 'animation__walking_and_idle', 'animation__small_sprites', 'animation__8_dir_rotation'). - **return_spritesheet** (boolean) - Required - Set to true to receive the output as a spritesheet. ### Request Example ```json { "prompt": "brave adventurer with backpack and hiking gear", "width": 48, "height": 48, "num_images": 1, "seed": 555, "prompt_style": "animation__four_angle_walking", "return_spritesheet": true } ``` ### Response #### Success Response (200) - **base64_images** (array of strings) - A list containing a single base64 encoded spritesheet image. #### Response Example ```json { "base64_images": [ "base64_encoded_spritesheet_image" ], "credit_cost": 1, "remaining_credits": 97 } ``` ``` -------------------------------- ### Generate Sprite Animations (Python) Source: https://context7.com/retro-diffusion/api-examples/llms.txt Creates various types of sprite sheet animations, including walking, idle, and rotational animations. Supports different prompt styles and requires specifying output dimensions. ```python import requests import base64 url = "https://api.retrodiffusion.ai/v1/inferences" headers = { "X-RD-Token": "rdpk-your-api-key-here" } # Four-directional walking animation with spritesheet output payload = { "prompt": "brave adventurer with backpack and hiking gear", "width": 48, "height": 48, "num_images": 1, "seed": 555, "prompt_style": "animation__four_angle_walking", "return_spritesheet": True } response = requests.post(url, headers=headers, json=payload) if response.status_code == 200: data = response.json() spritesheet_data = base64.b64decode(data['base64_images'][0]) with open("adventurer_spritesheet.png", "wb") as f: f.write(spritesheet_data) print("Spritesheet generated successfully") # Walking and idle combined animation payload_idle = { "prompt": "knight in plate armor", "width": 48, "height": 48, "num_images": 1, "prompt_style": "animation__walking_and_idle", "return_spritesheet": True } response_idle = requests.post(url, headers=headers, json=payload_idle) if response_idle.status_code == 200: data_idle = response_idle.json() with open("knight_walk_idle.png", "wb") as f: f.write(base64.b64decode(data_idle['base64_images'][0])) # Small sprites animation (32x32 only) small_sprites_payload = { "prompt": "tiny wizard character", "width": 32, "height": 32, "num_images": 1, "prompt_style": "animation__small_sprites", "return_spritesheet": True } # Eight-directional rotation (80x80 only) rotation_payload = { "prompt": "futuristic spaceship", "width": 80, "height": 80, "num_images": 1, "prompt_style": "animation__8_dir_rotation", "return_spritesheet": True } ``` -------------------------------- ### Generate Image with Palette Reference (Python) Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Generates an image using a prompt and a base64 encoded palette as a reference. The `input_palette` parameter should be a small, non-transparent image. Parameters include `prompt`, `width`, `height`, `num_images`, `seed`, and `input_palette`. ```python { "prompt": "a raven with a glowing green eye", "width": 256, "height": 256, "num_images": 1, "seed": 1234, "input_palette": "iVBORw0KGgoAAAANSUhEUgAAAUA... ... ..." } ``` -------------------------------- ### Check Remaining Credits Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Retrieve the number of remaining credits by making a GET request to the credits endpoint with your API key. ```APIDOC ## How can I check my remaining credits? ### Description To check your remaining credits, send a GET request to the `/v1/inferences/credits` endpoint. Ensure you include your API key in the `X-RD-Token` header. ### Method GET ### Endpoint `https://api.retrodiffusion.ai/v1/inferences/credits` ### Headers - **X-RD-Token** (string) - Required - Your API key. ### Response #### Success Response (200) - **credits** (integer) - The number of credits remaining. ### Response Example ```json { "credits": 999 } ``` ``` -------------------------------- ### POST /v1/inferences (Generate Full Tileset) Source: https://context7.com/retro-diffusion/api-examples/llms.txt Create complete tilesets with wang-style tile combinations for seamless map building. Supports basic and advanced modes with inside/outside texture definitions. Tile sizes range between 16x16 and 32x32. ```APIDOC ## POST /v1/inferences (Generate Full Tileset) ### Description Create complete tilesets with wang-style tile combinations for seamless map building. Supports basic and advanced modes with inside/outside texture definitions. Tile sizes range between 16x16 and 32x32. ### Method POST ### Endpoint /v1/inferences ### Parameters #### Header Parameters - **X-RD-Token** (string) - Required - Your API key. #### Request Body (Basic Tileset) - **width** (integer) - Required - The width of the tileset. Must be between 16 and 32. - **height** (integer) - Required - The height of the tileset. Must be between 16 and 32. - **prompt** (string) - Required - The text prompt describing the main texture of the tileset. - **num_images** (integer) - Optional - The number of tilesets to generate. Defaults to 1. - **prompt_style** (string) - Required - The style of tileset. Must be `rd_tile__tileset` for basic tilesets. - **seed** (integer) - Optional - The seed for random number generation. #### Request Body (Advanced Tileset) - **width** (integer) - Required - The width of the tileset. Must be between 16 and 32. - **height** (integer) - Required - The height of the tileset. Must be between 16 and 32. - **prompt** (string) - Required - The text prompt describing the main texture of the tileset. - **extra_prompt** (string) - Required - The text prompt describing the secondary texture (e.g., grass, path). - **num_images** (integer) - Optional - The number of tilesets to generate. Defaults to 1. - **prompt_style** (string) - Required - The style of tileset. Must be `rd_tile__tileset_advanced` for advanced tilesets. - **seed** (integer) - Optional - The seed for random number generation. ### Request Example (Basic) ```json { "width": 32, "height": 32, "prompt": "ancient stone dungeon floor with moss", "num_images": 1, "prompt_style": "rd_tile__tileset", "seed": 777 } ``` ### Request Example (Advanced) ```json { "width": 32, "height": 32, "prompt": "grey cobblestone path with cracks", "extra_prompt": "lush green grass with small flowers", "num_images": 1, "prompt_style": "rd_tile__tileset_advanced", "seed": 888 } ``` ### Response #### Success Response (200) - **base64_images** (array of strings) - An array containing the base64 encoded generated tileset image(s). - **credit_cost** (integer) - The number of credits consumed for the request. #### Response Example ```json { "base64_images": ["base64_encoded_tileset_string"], "credit_cost": 1 } ``` ``` -------------------------------- ### Generate Image with Palette and Pre-Palette Option (Python) Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Generates an image using a prompt and a base64 encoded palette, with an option to return the original image before the palette is applied. Set `return_pre_palette` to `true` for this functionality. Parameters include `prompt`, `width`, `height`, `num_images`, `seed`, `input_palette`, and `return_pre_palette`. ```python { "prompt": "a raven with a glowing green eye", "width": 256, "height": 256, "num_images": 1, "seed": 1234, "input_palette": "iVBORw0KGgoAAAANSUhEUgAAAUA... ... ...", "return_pre_palette": true } ``` -------------------------------- ### Generate Pixel Art Image with Python Source: https://context7.com/retro-diffusion/api-examples/llms.txt Generates pixel art images from a text prompt using the RetroDiffusion API. This example shows how to send a POST request with payload, handle the response, and save the generated image. Requires the 'requests' and 'base64' libraries. ```python import requests url = "https://api.retrodiffusion.ai/v1/inferences" headers = { "X-RD-Token": "rdpk-your-api-key-here" } payload = { "width": 256, "height": 256, "prompt": "A valiant knight in shining armor holding a magical sword", "prompt_style": "rd_fast__detailed", "num_images": 2, "seed": 42 } response = requests.post(url, headers=headers, json=payload) if response.status_code == 200: data = response.json() print(f"Credit cost: {data['credit_cost']}") print(f"Remaining credits: {data['remaining_credits']}") print(f"Generated {len(data['base64_images'])} images") # Save first image import base64 with open("knight.png", "wb") as f: f.write(base64.b64decode(data['base64_images'][0])) else: print(f"Error: {response.status_code} - {response.text}") ``` -------------------------------- ### Bypass Prompt Expansion Source: https://github.com/retro-diffusion/api-examples/blob/main/README.md Disable prompt expansion for your requests by setting the `bypass_prompt_expansion` parameter to true. ```APIDOC ## Ignoring prompt expansion ### Description Control prompt expansion behavior by using the `bypass_prompt_expansion` parameter. Setting it to `true` will disable prompt expansion for the current request. ### Method POST ### Endpoint `/api/images` (Assumed, as not explicitly stated but implied by payload structure) ### Parameters #### Request Body - **prompt** (string) - Required - The text prompt for image generation. - **width** (integer) - Required - The desired width of the image. - **height** (integer) - Required - The desired height of the image. - **bypass_prompt_expansion** (boolean) - Required - Set to `true` to disable prompt expansion. ### Request Example ```json { "prompt": "a raven with a glowing green eye", "width": 128, "height": 128, "bypass_prompt_expansion": true } ``` ``` -------------------------------- ### POST /v1/inferences (Generate Visual Effects Animation) Source: https://context7.com/retro-diffusion/api-examples/llms.txt Create looping VFX animations for game effects like explosions, fire, lightning, and magical spells. Outputs transparent GIF or spritesheet format. Supports sizes between 24x24 and 96x96 with square aspect ratios only. ```APIDOC ## POST /v1/inferences (Generate Visual Effects Animation) ### Description Create looping VFX animations for game effects like explosions, fire, lightning, and magical spells. Outputs transparent GIF or spritesheet format. Supports sizes between 24x24 and 96x96 with square aspect ratios only. ### Method POST ### Endpoint /v1/inferences ### Parameters #### Header Parameters - **X-RD-Token** (string) - Required - Your API key. #### Request Body - **prompt** (string) - Required - The text prompt describing the desired VFX animation. - **width** (integer) - Required - The width of the animation in pixels. Must be between 24 and 96. - **height** (integer) - Required - The height of the animation in pixels. Must be between 24 and 96 and equal to width. - **num_images** (integer) - Optional - The number of images to generate. Defaults to 1. - **prompt_style** (string) - Required - The style of animation. Must be `animation__vfx` for VFX animations. - **seed** (integer) - Optional - The seed for random number generation. - **return_spritesheet** (boolean) - Optional - Whether to return the animation as a spritesheet. If `false`, returns a GIF. Defaults to `false`. ### Request Example ```json { "prompt": "blue lightning bolt strike", "width": 48, "height": 48, "num_images": 1, "prompt_style": "animation__vfx", "seed": 100, "return_spritesheet": false } ``` ### Response #### Success Response (200) - **base64_images** (array of strings) - An array containing the base64 encoded generated animation(s) (as GIF or spritesheet). #### Response Example ```json { "base64_images": ["base64_encoded_animation_string"], "credit_cost": 1 } ``` ```