GluelyAI TikTok app - Go viral!Get It Free

How to Upscale Images With ClarityAI via API: A Developer's Guide

7 min read
How to Upscale Images With ClarityAI via API: A Developer's Guide

If you have ever tried enlarging a photograph and watched it dissolve into a blurry mess, you already understand why AI upscaling matters. ClarityAI is one of the strongest open-source upscalers available today, and calling it through an API lets you integrate super-resolution into any application without managing GPUs yourself. This guide walks through authentication, parameter tuning, provider selection, and production tips that keep your image enhancement pipeline running smoothly.

The model behind ClarityAI builds on Stable Diffusion XL with a tile-based diffusion approach. It breaks input into overlapping tiles, upscales each one, then stitches them back together. The result is sharp, coherent output even on images larger than 8,000 pixels on each side. Several API-first platforms now host the model, each with slightly different pricing and parameter sets.

Choosing an API Provider

ClarityAI is available through multiple inference providers. On fal.ai, you get both the classic Clarity Upscaler (fal-ai/clarity-upscaler) and the newer Crystal Upscaler, with pay-per-second GPU billing. On Replicate, the philz1337x/clarity-upscaler model runs on serverless GPUs with an asynchronous prediction API. The ClarityAI team also offers a direct hosted endpoint at api-upscale.clarityai.co priced at $0.03 per output megapixel. If you already use one of these platforms for AI image generation, staying on the same provider simplifies billing.

Authentication and Setup

Every provider requires an API key. For fal.ai, sign up and generate a key from your dashboard, then set FAL_KEY in your environment. Requests go to https://fal.run/fal-ai/clarity-upscaler with a Key authorization header. For Replicate, copy your API token from account settings and set REPLICATE_API_TOKEN. The direct ClarityAI endpoint uses Authorization: Bearer YOUR_API_KEY against https://api-upscale.clarityai.co. All three accept JSON payloads and return image URLs. If you are building a production batch processing system, wrapping the provider logic behind a thin adapter keeps your application portable.

Magnifying glass on a photographic print

Calling the API: curl and Python Examples

Here is a minimal curl example using fal.ai:

curl -X POST "https://fal.run/fal-ai/clarity-upscaler" \
  -H "Authorization: Key $FAL_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/photo.jpg",
    "prompt": "masterpiece, best quality, highres",
    "creativity": 0.35,
    "resemblance": 0.9,
    "scale_factor": 2
  }'

And the equivalent in Python:

import requests, os

resp = requests.post(
    "https://fal.run/fal-ai/clarity-upscaler",
    headers={
        "Authorization": f"Key {os.environ['FAL_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "image_url": "https://example.com/photo.jpg",
        "prompt": "masterpiece, best quality, highres",
        "creativity": 0.35,
        "resemblance": 0.9,
        "scale_factor": 2,
    },
)
print(resp.json()["image"]["url"])

The response includes the upscaled image URL and run metadata. For Replicate, the flow is asynchronous: you create a prediction, then poll or use a webhook. If you are already orchestrating multi-step image operations through an AI workflow tool, these API calls slot in as one node in a larger pipeline.

Key Parameters and How to Tune Them

Getting the right output comes down to balancing a few core parameters. The creativity setting (float, 0.0 to 1.0, default ~0.35) controls how much the model invents versus preserves. For photographs, 0.2 to 0.4 works well; for illustrations, push to 0.5 to 0.7. The resemblance setting works opposite: higher values constrain the model to match the original more closely, and product photos typically need 0.8 or above. The scale_factor (2 or 4) determines enlargement size, and the prompt guides the upscaler's generative pass, with the default "masterpiece, best quality, highres" serving most inputs. Developers exploring AI image editing tools for the first time often overlook how much tuning these values improves output.

Production Tips and Cost Management

Running the Clarity Upscaler at scale is different from calling it once in a notebook. Queue your jobs and process 3 to 5 in parallel, with retries on 429 responses, rather than firing all requests simultaneously. The same concurrency principles apply when building REST-based AI pipelines for other generative tasks.

On cost: fal.ai charges per GPU-second, with a typical 2x upscale of a 1024x1024 image taking 8 to 15 seconds on an A100 (roughly $0.02 to $0.04). ClarityAI Direct charges $0.03 per output megapixel, so the same 2x upscale costs about $0.12. At high volumes, GPU-second pricing usually wins if you keep the model warm. Developers managing code-to-image workflows know that compute cost hinges on cold-start management and input caching.

Server rack with blinking lights in a dim room

Comparing Clarity Upscaler Variants

The ClarityAI ecosystem includes several specialized models. The Clarity Upscaler (Classic) is the original general-purpose option with LoRA injection, custom checkpoints, and tile control. The Crystal Upscaler is optimized for faces, skin texture, and product imagery with fewer parameters. Clarity Pro is a portrait-focused variant with only four inputs. For most free AI image generation outputs, Classic with default settings produces excellent results at 2x; Crystal is better for headshots and product catalog photos.

FAQ

What image formats does the ClarityAI API accept?

All three providers accept JPEG and PNG via URL. The direct API also accepts base64-encoded images. Output is typically PNG, though you can request JPEG or WebP through the output_format parameter. If you are generating source images with AI before upscaling, PNG input preserves the most detail.

What is the maximum image size the Clarity Upscaler can handle?

The model supports outputs up to roughly 13,000 x 13,000 pixels. On the direct API, the ceiling is 64 megapixels. Most production use cases stay within 2x to 4x. Teams building automated image enhancement typically stay at 2x for web assets and reserve 4x for print.

How does creativity affect upscaling quality?

Lower values (0.1 to 0.3) preserve the original closely, adding subtle sharpening. Higher values (0.5 to 0.9) allow the model to hallucinate texture, which adds perceived detail but can introduce artifacts. For most photo editing tasks, start at 0.3 and adjust up only if the output looks soft.

Can I use the Clarity Upscaler with my own Stable Diffusion checkpoint?

Yes, on fal.ai and Replicate. Both expose a sd_model parameter. The default is Juggernaut Reborn, but you can swap in any SDXL-compatible checkpoint. This flexibility is similar to how code-driven AI workflows let you swap models at each step.

Is the Clarity Upscaler free to use?

The underlying model is open source (MIT license). You can self-host it on your own GPU at no API cost. Hosted APIs charge for compute, with typical costs from $0.02 to $0.12 per image depending on size and provider. Self-hosting makes sense for teams already running GPU infrastructure for batch image generation.

How does Clarity compare to Magnific AI?

Magnific popularized AI-powered creative upscaling with a polished UI. Clarity is the open-source alternative that achieves comparable results on most inputs, with the added benefits of API access, self-hosting, and LoRA customization. For developers building automated pipelines, Clarity's API-first design is the practical choice.

Can I upscale AI-generated images for print resolution?

Absolutely. A common pattern is generating a 1024x1024 image with FLUX or Stable Diffusion, then running it through the Clarity Upscaler at 4x to produce a 4096x4096 output suitable for print. Teams that orchestrate these steps through an AI image editing suite typically chain generation and upscaling into a single automated run, reducing manual handoff.

Conclusion

ClarityAI gives developers a reliable path to high-resolution image upscaling without managing GPU infrastructure. The integration is straightforward regardless of provider: authenticate, POST your image and parameters, and receive a sharpened result. The key to good output is tuning creativity and resemblance for your specific image type, then building sensible batching and caching for production loads. For teams processing large volumes of AI-generated images, the Clarity Upscaler remains one of the most cost-effective options available today.