How to Test HiDream-I1 Image Generation via API

Steven Ang Cheong Seng

Steven Ang Cheong Seng

22 April 2025

How to Test HiDream-I1 Image Generation via API

It seems like for every week, we get a new AI Image Generation models capable of creating stunning visuals. One such powerful model is HiDream-I1-Full. While running these models locally can be resource-intensive, leveraging APIs provides a convenient and scalable way to integrate this technology into your applications or workflows.

This tutorial will guide you through:

  1. Understanding HiDream-I1-Full: What it is and its capabilities.
  2. API Options: Exploring two popular platforms offering HiDream-I1-Full via API: Replicate and Fal.ai.
  3. Testing with Apidog: A step-by-step guide on how to interact with and test these APIs using the Apidog tool.
💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demans, and replaces Postman at a much more affordable price!
button

Target Audience: Developers, designers, AI enthusiasts, and anyone interested in using advanced AI image generation without complex local setups.

Prerequisites:

What is HiDream-I1-Full?

HiDream AI: the New King of AI Image Generation?

HiDream-I1-Full is an advanced text-to-image diffusion model developed by HiDream AI. It belongs to the family of models designed to generate high-quality, coherent, and aesthetically pleasing images based on textual descriptions (prompts).

Model Details: You can find the official model card and more technical information on Hugging Face: https://huggingface.co/HiDream-ai/HiDream-I1-Full

Key Capabilities (Typical for models of this class):

HiDream AI's Bechmarks Comparing to GOT-4o, Recraft V3, Google Image 3, Ideogram 3.0 and FLUX (Source: ArtificialAnalysis)

Why Use an API?

Running large AI models like HiDream-I1-Full locally requires significant computational resources (powerful GPUs, ample RAM, and storage) and technical setup (managing dependencies, model weights, environment configurations). Using an API offers several advantages:

How to Use HiDream-I1-Full via API

Several platforms host AI models and provide API access. We will focus on two popular choices for HiDream-I1-Full:

Option 1: Use Replicate's HiDream API

Replicate is a platform that makes it easy to run machine learning models via a simple API, without needing to manage infrastructure. They host a vast library of community-published models.

How Replicate Works:

  1. Authentication: You need a Replicate API token, which you can find in your account settings. This token is passed in the Authorization header.
  2. Starting a Prediction: You send a POST request to the Replicate API endpoint for predictions. The request body contains the model version and the input parameters (like prompt, negative_prompt, seed, etc.).
  3. Asynchronous Operation: Replicate typically operates asynchronously. The initial POST request returns immediately with a prediction ID and URLs to check the status.
  4. Getting Results: You need to poll the status URL (provided in the initial response) using GET requests until the status is succeeded (or failed). The final successful response will contain the URL(s) of the generated image(s).

Conceptual Python Example (using requests):

import requests
import time
import os

REPLICATE_API_TOKEN = "YOUR_REPLICATE_API_TOKEN" # Use environment variables in production
MODEL_VERSION = "TARGET_MODEL_VERSION_FROM_REPLICATE_PAGE" # e.g., "9a0b4534..."

# 1. Start Prediction
headers = {
    "Authorization": f"Token {REPLICATE_API_TOKEN}",
    "Content-Type": "application/json"
}
payload = {
    "version": MODEL_VERSION,
    "input": {
        "prompt": "A majestic cyberpunk cityscape at sunset, neon lights reflecting on wet streets, detailed illustration",
        "negative_prompt": "ugly, deformed, blurry, low quality, text, watermark",
        "width": 1024,
        "height": 1024,
        "seed": 12345
        # Add other parameters as needed based on the Replicate model page
    }
}

start_response = requests.post("<https://api.replicate.com/v1/predictions>", json=payload, headers=headers)
start_response_json = start_response.json()

if start_response.status_code != 201:
    print(f"Error starting prediction: {start_response_json.get('detail')}")
    exit()

prediction_id = start_response_json.get('id')
status_url = start_response_json.get('urls', {}).get('get')

print(f"Prediction started with ID: {prediction_id}")
print(f"Status URL: {status_url}")

# 2. Poll for Results
output_image_url = None
while True:
    print("Checking status...")
    status_response = requests.get(status_url, headers=headers)
    status_response_json = status_response.json()

    status = status_response_json.get('status')
    if status == 'succeeded':
        output_image_url = status_response_json.get('output') # Usually a list of URLs
        print("Prediction succeeded!")
        print(f"Output: {output_image_url}")
        break
    elif status == 'failed' or status == 'canceled':
        print(f"Prediction failed or canceled: {status_response_json.get('error')}")
        break
    elif status in ['starting', 'processing']:
        # Wait before polling again
        time.sleep(5) # Adjust polling interval as needed
    else:
        print(f"Unknown status: {status}")
        print(status_response_json)
        break

# Now you can use the output_image_url

Pricing: Replicate charges based on the execution time of the model on their hardware. Check their pricing page for details.

Option 2: Fal.ai

Fal.ai is another platform focused on providing fast, scalable, and cost-effective inference for AI models via APIs. They often emphasize real-time performance.

How Fal.ai Works:

  1. Authentication: You need Fal API credentials (Key ID and Key Secret, often combined as KeyID:KeySecret). This is passed in the Authorization header, typically as Key YourKeyID:YourKeySecret.
  2. API Endpoint: Fal.ai provides a direct endpoint URL for the specific model function.
  3. Request Format: You send a POST request to the model's endpoint URL. The request body is typically JSON containing the input parameters required by the model (similar to Replicate: prompt, etc.).
  4. Synchronous vs. Asynchronous: Fal.ai can offer both. For potentially long-running tasks like image generation, they might use:

Conceptual Python Example (using requests - assuming async queue):

import requests
import time
import os

FAL_API_KEY = "YOUR_FAL_KEY_ID:YOUR_FAL_KEY_SECRET" # Use environment variables
MODEL_ENDPOINT_URL = "<https://fal.run/fal-ai/hidream-i1-full>" # Check the exact URL on Fal.ai

# 1. Submit Request to Queue (Example - check Fal docs for exact structure)
headers = {
    "Authorization": f"Key {FAL_API_KEY}",
    "Content-Type": "application/json"
}
payload = {
    # Parameters are often directly in the payload for Fal.ai serverless functions
    # or within an 'input' object depending on the setup. Check the docs!
    "prompt": "A hyperrealistic portrait of an astronaut floating in space, Earth reflecting in the helmet visor",
    "negative_prompt": "cartoon, drawing, illustration, sketch, text, letters",
    "seed": 98765
    # Add other parameters supported by the Fal.ai implementation
}

# Fal.ai might require adding '/queue' or specific query params for async
# Example: POST <https://fal.run/fal-ai/hidream-i1-full/queue>
# Check their documentation! Assuming an endpoint that returns a status URL:

submit_response = requests.post(f"{MODEL_ENDPOINT_URL}", json=payload, headers=headers, params={"fal_webhook": "OPTIONAL_WEBHOOK_URL"}) # Check docs for query params like webhook

if submit_response.status_code >= 300:
    print(f"Error submitting request: {submit_response.status_code}")
    print(submit_response.text)
    exit()

submit_response_json = submit_response.json()

# Fal.ai's async response might differ - it could return a request_id or a direct status URL
# Assuming it returns a status URL similar to Replicate for this conceptual example
status_url = submit_response_json.get('status_url') # Or construct from request_id, check docs
request_id = submit_response_json.get('request_id') # Alternative identifier

if not status_url and request_id:
     # You might need to construct the status URL, e.g., <https://fal.run/fal-ai/hidream-i1-full/requests/{request_id}/status>
     # Or query a generic status endpoint: <https://fal.run/requests/{request_id}/status>
     print("Need to construct status URL or use request_id, check Fal.ai documentation.")
     exit() # Needs specific implementation based on Fal docs

print(f"Request submitted. Status URL: {status_url}")

# 2. Poll for Results (if async)
output_data = None
while status_url: # Only poll if we have a status URL
    print("Checking status...")
    # Polling might require authentication too
    status_response = requests.get(status_url, headers=headers)
    status_response_json = status_response.json()

    status = status_response_json.get('status') # Check Fal.ai docs for status keys ('COMPLETED', 'FAILED', etc.)

    if status == 'COMPLETED': # Example status
        output_data = status_response_json.get('response') # Or 'result', 'output', check docs
        print("Request completed!")
        print(f"Output: {output_data}") # Output structure depends on the model on Fal.ai
        break
    elif status == 'FAILED': # Example status
        print(f"Request failed: {status_response_json.get('error')}") # Check error field
        break
    elif status in ['IN_PROGRESS', 'IN_QUEUE']: # Example statuses
        # Wait before polling again
        time.sleep(3) # Adjust polling interval
    else:
        print(f"Unknown status: {status}")
        print(status_response_json)
        break

# Use the output_data (which might contain image URLs or other info)

Pricing: Fal.ai typically charges based on execution time, often with per-second billing. Check their pricing details for the specific model and compute resources.

Test HiDream API with Apidog

Apidog is a powerful API design, development, and testing tool. It provides a user-friendly interface to send HTTP requests, inspect responses, and manage API details, making it ideal for testing the Replicate and Fal.ai APIs before integrating them into code.

button

Steps to Test HiDream-I1-Full API using Apidog:

Step 1. Install and Open Apidog: Download and install Apidog or use its web version. Create an account if necessary.

Step 2. Create a New Request:

Step 3. Set HTTP Method and URL:

Step 4. Configure Headers:

Add the Content-Type header:

Add the Authorization header:

For Replicate:

For Fal.ai:

Step 5. Configure Request Body:

Go to the Body tab.

Select the raw format and choose JSON from the dropdown.

Paste the JSON payload according to the platform's requirements.

Example JSON Body for Replicate:

{
  "version": "PASTE_MODEL_VERSION_FROM_REPLICATE_PAGE_HERE",
  "input": {
    "prompt": "A watercolor painting of a cozy library corner with a sleeping cat",
    "negative_prompt": "photorealistic, 3d render, bad art, deformed",
    "width": 1024,
    "height": 1024,
    "seed": 55555
  }
}

Example JSON Body for Fal.ai

{
  "prompt": "A watercolor painting of a cozy library corner with a sleeping cat",
  "negative_prompt": "photorealistic, 3d render, bad art, deformed",
  "width": 1024,
  "height": 1024,
  "seed": 55555
  // Other parameters like 'model_name' might be needed depending on Fal.ai setup
}

Important: Refer to the specific documentation on the Replicate or Fal.ai pages for the exact required and optional parameters for the HiDream-I1-Full model version you are using. Parameters like guidance_scale, num_inference_steps, etc., might be available.

Step 6. Send the Request:

Poll for Results (for Asynchronous APIs):

View the Image: Copy the image URL from the final successful response and paste it into your web browser to view the generated image.

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demans, and replaces Postman at a much more affordable price!
button

Conclusion

HiDream-I1-Full offers powerful image generation capabilities, and using APIs from platforms like Replicate or Fal.ai makes this technology accessible without managing complex infrastructure. By understanding the API workflow (request, potential polling, response) and utilizing tools like Apidog for testing, you can easily experiment with and integrate state-of-the-art AI image generation into your projects.

Remember to always consult the specific documentation on Replicate and Fal.ai for the most up-to-date endpoint URLs, required parameters, authentication methods, and pricing details, as these can change over time. Happy generating!

Explore more

Beyond the Trial: 5 Simple Ways to Use Augment Code for Free

Beyond the Trial: 5 Simple Ways to Use Augment Code for Free

Stretching your budget? Explore 5 straightforward methods to access Augment Code's powerful features without cost. We delve into free plans, trials, open-source programs, and community solutions.

3 June 2025

Top 10 Stablecoin APIs for Developers

Top 10 Stablecoin APIs for Developers

Stablecoins have become a vital component of the cryptocurrency ecosystem, offering traders and developers a way to mitigate market volatility while still benefiting from blockchain technology. Whether you are designing a payment solution, executing automated trading strategies, or providing real-time market analytics, incorporating stablecoin APIs into your platform can help streamline processes and enhance functionality. In this article, we explore the top 10 stablecoin trading APIs for develo

31 May 2025

Top 10 Best Online Sports Betting APIs / Sports Odds APIs 2025

Top 10 Best Online Sports Betting APIs / Sports Odds APIs 2025

The online sports betting industry is evolving at an unprecedented pace, and with it comes the need for robust, real-time data integration. In 2025, sports betting APIs and sports odds APIs are more vital than ever for bookmakers, developers, and betting enthusiasts. This article dives into the top 10 online sports betting APIs that are set to shape the industry this year, with betcore.eu proudly leading the pack as the number one choice. With technology continually advancing and customer expec

31 May 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs