Skip to main content
In this tutorial, you’ll deploy a pre-built SDXL Turbo from the and integrate it into a web application. The frontend sends prompts to a small backend server, which calls your endpoint and returns the generated image for the page to display. Because only the backend calls the endpoint, your API key never reaches the browser.

What you’ll learn

  • How to deploy a endpoint from the Hub.
  • How to send a test request to your endpoint.
  • How to call your endpoint from a backend server so your API key stays out of client-side code.
  • How to build a frontend that displays the generated images.

Requirements

Step 1: Deploy an endpoint from the Hub

The Runpod Hub provides pre-built workers you can deploy with a few clicks. For this tutorial, you’ll deploy the SDXL Turbo worker, which generates images from text prompts.
  1. Navigate to the Runpod Hub in the console.
  2. Search for “SDXL-turbo” or browse the image generation category.
  3. Select the SDXL-turbo worker to view its details and hardware requirements.
  4. Click Deploy in the top-right corner of the page.
  5. Click Create Endpoint.
Your endpoint will be ready within a few minutes. You can monitor the deployment status on your Serverless endpoints page.

Step 2: Find your endpoint ID and API key

Now that your endpoint is deployed, you’ll need your endpoint ID and API key to make requests.

Find your endpoint ID

  1. Go to your Serverless endpoints page.
  2. Click on your SDXL Turbo endpoint.
  3. Copy the Endpoint ID shown at the top of the page.

Find your API key

  1. Navigate to Settings > API Keys in the console, or go directly to the API Keys page.
  2. Copy an existing API key, or create a new one with read and write permissions.
Anyone who has your API key can create, modify, and delete resources on your Runpod account. The key’s permissions set the limit. Never commit it to version control or include it in code that runs in the browser. In this tutorial, the key stays on your backend server.

Step 3: Send a test request

Test your endpoint with a simple API request before integrating it into an application. The endpoint accepts a JSON payload with an input object containing your prompt.
Replace the following placeholders: The generated image is returned as a base64-encoded PNG string in output.images[0].image. For more information about request parameters and response formats, see Send requests. SDXL Turbo uses adversarial diffusion distillation to generate images in just a few steps. The worker is pre-configured with optimal settings, so you only need to provide the prompt parameter, but you can also provide other parameters to control the generation process.

Step 4: Integrate with a web application

Now that you’ve confirmed your endpoint is working, you can integrate it into a web application. This example creates a simple image generator with an input field for prompts and a button to generate images. The application has two parts. The frontend runs in the browser and sends each prompt to your own backend. The backend is a small Flask server that holds your API key, calls your Runpod endpoint, and returns only the generated image. This tutorial uses Python for the backend, but you can write it in any language or framework that can send HTTP requests. Create three files in the same directory:
The HTML file sets up a user interface with an input field for prompts and a button to generate images. Clicking the button calls the generateImage function in script.js.
index.html

Step 5: Run your application

Run the backend server, which serves the frontend and handles requests to your endpoint.
1

Install the dependencies

In the directory containing your files, install Flask and the requests library:
2

Set your endpoint ID and API key

Set the environment variables that server.py reads. Replace YOUR_ENDPOINT_ID with your endpoint ID from step 2 and YOUR_API_KEY with your Runpod API key.
These variables last only for the current terminal session, so start the server from the same terminal.
3

Start the server

From the same directory, start the Flask server on port 8000:
4

Open the application

Open http://localhost:8000 in your browser.
Always open the application through http://localhost:8000. If you open index.html directly from your file system, the page loads from a file:// URL. That page can’t reach /api/generate because the route exists only on the Flask server.
Enter a prompt and click Generate Image to see your AI-generated image.
The first request may take longer (30-60 seconds) due to as the endpoint loads the model into GPU memory. Subsequent requests complete in just a few seconds.

Next steps

Now that you’ve integrated a Serverless endpoint into a web application, you can:
Last modified on November 22, 2026