Before we begin, ensure you have a Runpod API key, available under your user settings. This key is crucial for identification and billing purposes. Keep it secure! Also, remember to retrieve your results via the status endpoint within 30 minutes, as your inputs and outputs are not stored longer than this for privacy protection.
Overview
In this section, we’ll explore how Runpod’s API works. It’s asynchronous, meaning that when you send a request, you get a job ID back almost instantly. Next, we’ll show you how to use this job ID to check the status and retrieve your results. Let’s dive into an example using the Stable Diffusion v1 inference endpoint.Create a serverless worker
First, let’s set up your serverless worker. Begin by selecting Quick Deploy on the Runpod interface. Then choose Start from the Stable Diffusion v1.5 options. Pick a GPU, say a 24 GB GPU, and click Deploy. Here’s an example endpoint you might use:https://api.runpod.ai/v2/{ID}/runsync
Start Your Job
Now, to initiate a job, you’ll make a request like the one shown below. This sends your parameters to the API and starts the process.Check the Status of Your Job
Since your initial response doesn’t include the output, a subsequent call is necessary. Use your job ID to check the job’s status as follows:Get Completed Job Status
Once your job is complete, you’ll receive a final response like this:Remember, you have up to 1 hour to retrieve your results via the status endpoint for privacy reasons.
Get Your Results
Finally, to view your results, decode the base64 image from the output. Here’s how you can do it in Python: