Image API

Type: Text to Image

POST https://api.rana.ai/v1/images/generations

Create images from text descriptions or from existing images as inspiration, using state-of-the-art open-source diffusion models.

Request Body


Required Parameters

Parameter Type Description
prompt String Concise text description of the desired image output, with a character limit of 1000 characters.

Optional Parameters

Parameter Type Default Description
guidance_scale Number model-dependent Fine-tune the level of prompt adherence, with greater values indicating a more accurate representation of the input.
model String dreamshaperv7 Identifier of the model to be used to generate the image(s).
n Integer 1 Image output count. This parameter specifies the number of images to generate, with a minimum of 1 and a maximum of 10.
negative_prompt String null Text description or list of words of undesired characteristics in the result’s output.
response_format String b64_json Object specifying the format of the model’s results. The generated images can be formatted in one of two: url or b64_json.
seed String null Enter a seed value to control the pseudo-random number generation process, enabling deterministic results.
size String 512x512 Size of generated images: 256x256 or 512x512.
steps Integer model-dependent Number of iterations for the denoising process.
stream Boolean false Choose whether to enable or disable streaming of the generation process.
style String null Select a pre-configured style to control the appearance outcome of the generated images.

Available Model IDs


Diffusion Models
Model Name Description
absolute_reality Specializes in ultra-high quality ‘fantasy-realistic’ images. Good at photorealism, detailed texturing, and atmospheric lighting.
anylora Versatile model capable of handling multiple art styles. Good for mixed media, style fusion, and experimental artwork.
anylora_anime_mix Hybrid variant of Anylora that generates anime-style art with other art styles.
dreamshaperv7 Popular fine-tuned model known for excellent composition and creative interpretations. Strong at character generation and scenic images.
dreamshaperv8 Latest iteration with improved facial details, lighting, and overall image coherence. Better handling of complex scenes and multiple subjects.
neverending-dream Focused on dreamlike and surreal imagery. Excels at surreal compositions, abstract concepts, and artistic interpretations.
realistic_vision_6 Focused on photorealistic outputs. Excels at portrait photography, product photography, architectural visualization, and natural landscapes.
segmind_vega_pix_detailed High-detail focused variant, ideal for complex textures, fine details, and intricate patterns.
segmind_vega_pix_flat Optimized for flat, graphic-style images. Good for UI/UX elements, icon design, and minimalist artwork.
segmind_vega_fp16 Performance-optimized version with FP16 precision. Faster generation times, lower memory usage, and good quality-to-performance ratio.
segmind_vega_rt Real-time optimized variant. Best for interactive applications, live generation, and quick iterations.
sd_1.5 Good for general-purpose image generation with balanced performance. Great starting point for most projects.
sd_2.1 Improved anatomy, face generation, and image composition. Better at handling complex prompts.
sd_turbo_or Optimized for speed, sacrificing some quality for faster generation. Ideal for rapid prototyping or quick results.
waifu_diffusion Specialized for anime and manga-style artwork. Optimized for anime characters, cel-shaded styling, manga-inspired compositions.
3D_animation Specialized in generating 3D-style images. Best for 3D character renders, animation-ready assets, CGI-style imagery.

Response Format

{
  "created": 1589478378,
  "data": [
    {
      "b64_json": "data:image/png;base64,...",
      "url": "https://ranaengine.app/<itemLocator>"
    }
  ]
}

Examples

cURL

curl https://api.rana.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $RANA_API_KEY" \
  -d '{
    "prompt": "A serene landscape at sunset",
    "negative_prompt": "blur, darkness, distortion",
    "n": 1,
    "size": "512x512"
  }'

Node.js

import { RanaAPI } from "rana-api";

const rana = new RanaAPI();

async function generateImage() {
  const response = await rana.images.generate({
    prompt: "A serene landscape at sunset",
    negative_prompt: "blur, darkness, distortion",
    n: 1,
    size: "512x512",
  });

  return response.data[0];
}

Type: Image to Image

POST https://api.rana.ai/v1/images/edits

Create variations or modifications of existing images using text prompts.

Request Body


Required Parameters

Parameter Type Description
image String Use a Base64-encoded image as a seed to generate new images.
prompt String Concise text description of the desired image output, with a character limit of 1000 characters.

Optional Parameters

Parameter Type Default Description
guidance_scale Number model-dependent Fine-tune the level of prompt adherence, with greater values indicating a more accurate representation of the input.
model String model-dependent Identifier of the model to be use to generate the image(s).
n Integer 1 Image output count. This parameter specifies the number of images to generate, with a minimum of 1 and a maximum of 10.
negative_prompt String null Text description or list of words of undesired characteristics in the result’s output.
response_format String b64_json An object specifying the format that the model must output. The generated images can be formatted in one of two: url or b64_json.
seed String null Enter a seed value to control the pseudo-random number generation process, enabling deterministic results.
size String 512x512 Size of generated images: 256x256 or 512x512.
steps Integer model-dependent Number of iterations for the denoising process.
stream Boolean true Choose whether to enable or disable streaming of the generation process.
strength Number 0.8 Adjust the amount of noise added to the output with a value between 0 and 1, where higher values result in more variation.
style String null Select a pre-configured style to control the appearance outcome of the generated images.

Response Format

{
  "created": 1589478378,
  "data": [
    {
      "b64_json": "data:image/png;base64,...",
      "url": "https://ranaengine.app/<itemLocator>"
    }
  ]
}

Examples

cURL

curl https://api.rana.ai/v1/images/edits \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $RANA_API_KEY" \
  -d '{
    "prompt": "Add snow to the landscape",
    "image": "base64_encoded_image_data",
    "negative_prompt": "blur, artifacts",
    "strength": 0.7
  }'

Node.js

import { RanaAPI } from "rana-api";

const rana = new RanaAPI();

async function editImage() {
  const response = await rana.images.edit({
    prompt: "Add snow to the landscape",
    image: "base64_encoded_image_data",
    negative_prompt: "blur, artifacts",
    strength: 0.7,
  });

  return response.data[0];
}