Skip to main content

Run your first AI API with Stable Diffusion

Job endpoints in RunPod are URLs that provide standard functionality for submitting jobs and retrieving the output from job requests.

To use these endpoints, you will need to have your endpoint ID.

The constructed URL will start with https://api.runpod.ai/v2/{endpoint_id}.

note

To run these commands, as is, export your RunPod API key as an environment variable.


export YOUR_API_KEY=<KEY>

Runsync

Runsync is a synchronous endpoint that runs your model and returns the result. It is useful for testing your model and debugging. Recommended for jobs that take less than 15 seconds.

For example, if you are using the Stable Diffusion v1 inference endpoint, you would make a request like the following:


curl -X POST https://api.runpod.ai/v2/stable-diffusion-v1/runsync \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-d '{"input": {"prompt": "a cute magical flying dog, fantasy art drawn by disney concept artists"}}'

You would get an immediate response that includes a unique job ID. You can then query the status endpoint and pass it your job ID. The status endpoint will give you the job results when completed.

Run

Run is an asynchronous endpoint that runs your model and returns a job ID. It is useful for running your model in the background. Recommended for jobs that take more than 15 seconds.

For example, if you are using the Stable Diffusion v1 inference endpoint, you would make a request like the following:


curl -X POST https://api.runpod.ai/v2/stable-diffusion-v1/run \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-d '{"input": {"prompt": "a cute magical flying dog, fantasy art drawn by disney concept artists"}}'

Status

Status is an endpoint that returns the status of your job.

For checking the status of your job, you would make a request like the following:


curl https://api.runpod.ai/v2/stable-diffusion-v1/status/1b30c19b-9729-46d0-b0fc-a2e96b9342fa-u1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${YOUR_API_KEY}"

Cancel

Cancel is an endpoint that cancels your job. It is useful for cancelling your job.


curl https://api.runpod.ai/v2/stable-diffusion-v1/cancel/1b30c19b-9729-46d0-b0fc-a2e96b9342fa-u1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${YOUR_API_KEY}"

Health

Health is an endpoint that returns the health of your serverless worker. It is useful for checking the health of your serverless worker. The health check is a utility function that can be called on any endpoint to provide worker and queue metrics.


curl --request GET \
--url https://api.runpod.ai/v2/stable-diffusion-v1/health \
--header "accept: application/json" \
--header "authorization: Bearer ${YOUR_API_KEY}"

note

You must retrieve your results via the status endpoint within 30 minutes as RunPod does not keep your inputs or outputs longer than that to protect your privacy.