Skip to content

Inputs and Outputs

In order for your inputs and outputs to be nicely rendered in the playground, you need to use certain conventions that tell our frontend how to interpret the data.

Files

File URL

Name your field with a file_url suffix and it will be rendered as a file in the playground, allowing users to upload or download the file.

from pydantic import BaseModel
class MyInput(BaseModel):
file_url: str
class MyOutput(BaseModel):
file_url: str

Alternatively if that naming convention is not suitable, you can also explicitly tell our frontend to treat it as a file:

from pydantic import BaseModel, Field
class MyInput(BaseModel):
foo: str = Field(..., ui={"field": "file"})
class MyOutput(BaseModel):
foo: str = Field(..., ui={"field": "file"})

File Data or URL

If you need your input or output to be able to carry url or data itself, you can also use the File class.

from fal.toolkit import File
from pydantic import BaseModel
class MyInput(BaseModel):
file: File
class MyOutput(BaseModel):
file: File
class MyApp(fal.App):
@fal.endpoint("/")
def predict(self, input: MyInput) -> MyOutput:
return MyOutput(file=input.file)

Images

Image URL

Name your field with a image_url suffix and it will be rendered as an image in the playground, allowing users to upload or download the image.

from pydantic import BaseModel
class MyInput(BaseModel):
image_url: str

Alternatively if that naming convention is not suitable, you can also explicitly tell our frontend to treat it as an image:

from pydantic import BaseModel, Field
class MyInput(BaseModel):
foo: str = Field(..., ui={"field": "image"})

Image Data or URL

If you need your input or output to be able to carry url or data itself, you can also use the Image class.

from fal.toolkit import Image
from pydantic import BaseModel
class MyInput(BaseModel):
image: Image
class MyOutput(BaseModel):
image: Image
class MyApp(fal.App):
@fal.endpoint("/")
def predict(self, input: MyInput) -> MyOutput:
return MyOutput(image=input.image)

Image Dataset

Use image_urls suffix to render a dataset of images in the playground.

from typing import List
from pydantic import BaseModel
class MyInput(BaseModel):
image_urls: List[str]

Audio

Audio URL

Name your field with a audio_url suffix and it will be rendered as an audio in the playground, allowing users to upload or download the audio.

from typing import List
from pydantic import BaseModel
class MyInput(BaseModel):
audio_url: str
class MyOutput(BaseModel):
audio_url: str

Alternatively if that naming convention is not suitable, you can also explicitly tell our frontend to treat it as an audio:

from pydantic import BaseModel, Field
class MyInput(BaseModel):
foo: str = Field(..., ui={"field": "audio"})

Audio Dataset

Use audio_urls suffix to render a dataset of audios in the playground.

from typing import List
from pydantic import BaseModel
class MyInput(BaseModel):
audio_urls: List[str]

Video

Video URL

Name your field with a video_url suffix and it will be rendered as a video in the playground, allowing users to upload or download the video.

from typing import List
from pydantic import BaseModel
class MyInput(BaseModel):
video_url: str
class MyOutput(BaseModel):
video_url: str

Alternatively if that naming convention is not suitable, you can also explicitly tell our frontend to treat it as a video:

from typing import List
from pydantic import BaseModel, Field
class MyInput(BaseModel):
foo: str = Field(..., ui={"field": "video"})

Video Dataset

Use video_urls suffix to render a dataset of videos in the playground.

from typing import List
from pydantic import BaseModel
class MyInput(BaseModel):
video_urls: List[str]