This quickstart walks you through generating an image using Runpod Public Endpoints. You’ll use the Flux Schnell model, which is optimized for fast generation.
Requirements
Step 1: Generate an image in the playground
The fastest way to test Public Endpoints is through the browser-based playground.
- Go to the Flux Schnell endpoint in the Runpod console.
- Under Input, enter a prompt:
A golden retriever playing fetch on a sunny beach (or any other prompt you like).
- Click Run.
- Wait a few seconds for the image to generate. The result appears under Result.
You’ve just generated your first image. The playground shows the estimated cost (~$0.0025 for a 1024x1024 image).
Step 2: Generate an image with the API
Now let’s generate an image programmatically using the REST API.
- Open a terminal on your local machine.
- Copy the following command, replacing
YOUR_API_KEY with your Runpod API key:
curl -X POST "https://api.runpod.ai/v2/black-forest-labs-flux-1-schnell/runsync" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "A golden retriever playing fetch on a sunny beach",
"width": 1024,
"height": 1024
}
}'
- Paste the command into your terminal and press Enter.
- Wait for the response (this takes about 10-20 seconds).
- Create a new file called
generate_image.py and paste the following code:
import requests
response = requests.post(
"https://api.runpod.ai/v2/black-forest-labs-flux-1-schnell/runsync",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"input": {
"prompt": "A golden retriever playing fetch on a sunny beach",
"width": 1024,
"height": 1024,
}
},
)
result = response.json()
print(result["output"]["image_url"])
- Replace
YOUR_API_KEY with your Runpod API key.
- Open a terminal, navigate to the directory containing the file, and run:
- Wait for the script to print the image URL (this takes about 10-20 seconds).
Response
Both methods return a JSON response with your generated image:
{
"status": "COMPLETED",
"output": {
"image_url": "https://image.runpod.ai/...",
"cost": 0.02097152
}
}
Open the image_url in your browser to view the generated image.
Image URLs expire after 7 days. Download images immediately if you need to keep them.
Next steps