Prerequisites
This section presumes you have an understanding of the terminal and can execute commands from your terminal. Before starting this tutorial, you’ll need access to:Runpod
To continue with this quick start, you’ll need access to the following from Runpod:- Runpod account
- Runpod API Key
Docker
To build your Docker image, you’ll need access to the following:- Docker installed
- Docker account
GitHub
To clone theworker-sdxl-turbo
repo, you’ll need access to the following:
- Git installed
- Permissions to clone GitHub repos
Build and push your Docker image
This step will walk you through building and pushing your Docker image to your container registry. This is useful to building custom images for your use case. If you prefer, you can use the prebuilt image from runpod/sdxl-turbo instead of building your own. Building a Docker image allows you to specify the container when creating a Worker. The Docker image includes the Runpod Handler which is how you provide instructions to Worker to perform some task. In this example, the Handler is responsible for taking a Job and returning a base 64 instance of the image.- Clone the Runpod Worker SDXL Turbo repository:
- Navigate to the root of the cloned repo:
- Build the Docker image:
- Push your container registry:
Deploy a Serverless Endpoint
The container you just built will run on the Worker you’re creating. Here, you will configure and deploy the Endpoint. This will include the GPU and the storage needed for your Worker. This step will walk you through deploying a Serverless Endpoint to Runpod.- Log in to the Runpod Serverless console.
- Select + New Endpoint.
-
Provide the following:
- Endpoint name.
- Select a GPU.
- Configure the number of Workers.
- (optional) Select FlashBoot.
- (optional) Select a template.
- Enter the name of your Docker image.
- For example,
runpod/sdxl-turbo:dev
.
- For example,
- Specify enough memory for your Docker image.
- Select Deploy.
Send a request
Now that our Endpoint is deployed, you can begin interacting with and integrating it into an application. Before writing the logic into the application, ensure that you can interact with the Endpoint by sending a request. Run the following command:YOUR_ENDPOINT
: The name of your Endpoint.YOUD_API_KEY
: The API Key required with read and write access.YOUR_PROMPT
: The custom prompt passed to the model.
PENDING
; but quickly change to COMPLETED
if you query the Job Id.
Integrate into your application
Now, let’s create a web application that can take advantage of writing a prompt and generate an image based on that prompt. While these steps are specific to JavaScript, you can make requests against your Endpoint in any language of your choice. To do that, you’ll create two files:index.html
: The frontend to your web application.script.js
: The backend which handles the logic behind getting the prompt and the call to the Serverless Endpoint.
The HTML file (
index.html
) sets up a user interface with an input box for the prompt and a button to trigger the image generation.index.html
- Replace
${process.env.REACT_APP_AUTH_TOKEN}
with your actual API key. - Replace
${process.env.REACT_APP_ENDPOINT_ID}
with your specific Endpoint. - Open
index.html
in a web browser, enter a prompt, and select Generate Image to see the result.
Run a server
You can run a server through Python or by opening theindex.html
page in your browser.
Run the following command to start a server locally using Python.