Error Error: No API found

In Zero GPU space, the space will not function without these descriptions.

import spaces # <= this!
from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained(...)
pipe.to('cuda')

@spaces.GPU # <= this!
def generate(prompt):
    return pipe(prompt).images

gr.Interface(
    fn=generate,
    inputs=gr.Text(),
    outputs=gr.Gallery(),
).launch()

Also, this is not limited to Zero GPU space, but the following error may still be unresolved.