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
- A Runpod account with credits.
- A Runpod API key.
- Python 3.8 or later, to run the backend server.
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.- Navigate to the Runpod Hub in the console.
- Search for “SDXL-turbo” or browse the image generation category.
- Select the SDXL-turbo worker to view its details and hardware requirements.
- Click Deploy in the top-right corner of the page.
- Click Create Endpoint.
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
- Go to your Serverless endpoints page.
- Click on your SDXL Turbo endpoint.
- Copy the Endpoint ID shown at the top of the page.

Find your API key
- Navigate to Settings > API Keys in the console, or go directly to the API Keys page.
- Copy an existing API key, or create a new one with read and write permissions.
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 aninput object containing your prompt.
- cURL
- Python
- Response
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:- index.html
- script.js
- server.py
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 These variables last only for the current terminal session, so start the server from the same terminal.
server.py reads. Replace YOUR_ENDPOINT_ID with your endpoint ID from step 2 and YOUR_API_KEY with your Runpod API key.- macOS/Linux
- Windows (PowerShell)
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.Next steps
Now that you’ve integrated a Serverless endpoint into a web application, you can:- Explore other workers on the Hub for different AI capabilities.
- Learn about asynchronous requests for handling long-running jobs.
- Build your own custom worker to deploy your own models.
- Use the Python SDK for more advanced integrations.