fal_client package

Submodules

fal_client.auth module

exception fal_client.auth.MissingCredentialsError

Bases: Exception

fal_client.auth.fetch_credentials()
Return type:

str

fal_client.client module

class fal_client.client.AppId(owner, alias, path, namespace)

Bases: object

alias: str
classmethod from_endpoint_id(endpoint_id)
Return type:

AppId

namespace: Optional[str]
owner: str
path: Optional[str]
class fal_client.client.AsyncCDNTokenManager(key)

Bases: object

async get_token()
Return type:

CDNToken

class fal_client.client.AsyncClient(key=None, default_timeout=120.0)

Bases: object

async cancel(application, request_id)
Return type:

None

default_timeout: float = 120.0
get_handle(application, request_id)
Return type:

AsyncRequestHandle

key: str | None = None
async result(application, request_id)
Return type:

Dict[str, Any]

async run(application, arguments, *, path='', timeout=None, hint=None)

Run an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return the result of the inference call directly.

Return type:

Dict[str, Any]

async status(application, request_id, *, with_logs=False)
Return type:

Status

async stream(application, arguments, *, path='/stream', timeout=None)

Stream the output of an application with the given arguments (which will be JSON serialized). This is only supported at a few select applications at the moment, so be sure to first consult with the documentation of individual applications to see if this is supported.

The function will iterate over each event that is streamed from the server.

Return type:

AsyncIterator[dict[str, Any]]

async submit(application, arguments, *, path='', hint=None, webhook_url=None, priority=None)

Submit an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return a handle to the request that can be used to check the status and retrieve the result of the inference call when it is done.

Return type:

AsyncRequestHandle

async subscribe(application, arguments, *, path='', hint=None, with_logs=False, on_enqueue=None, on_queue_update=None, priority=None)
async upload(data, content_type, file_name=None)

Upload the given data blob to the CDN and return the access URL. The content type should be specified as the second argument. Use upload_file or upload_image for convenience.

Return type:

str

async upload_file(path)

Upload a file from the local filesystem to the CDN and return the access URL.

Return type:

str

async upload_image(image, format='jpeg')

Upload a pillow image object to the CDN and return the access URL.

Return type:

str

class fal_client.client.AsyncRequestHandle(request_id, response_url, status_url, cancel_url, client)

Bases: _BaseRequestHandle

async cancel()

Cancel the request.

Return type:

None

client: AsyncClient
classmethod from_request_id(client, application, request_id)
Return type:

AsyncRequestHandle

async get()

Wait till the request is completed and return the result.

Return type:

Dict[str, Any]

async iter_events(*, with_logs=False, interval=0.1)

Continuously poll for the status of the request and yield it at each interval till the request is completed. If with_logs is True, logs will be included in the response.

Return type:

AsyncIterator[Status]

async status(*, with_logs=False)

Returns the status of the request (which can be one of the following: Queued, InProgress, Completed). If with_logs is True, logs will be included for InProgress and Completed statuses.

Return type:

Status

class fal_client.client.CDNToken(token, token_type, base_upload_url, expires_at)

Bases: object

base_upload_url: str
expires_at: datetime
is_expired()
Return type:

bool

token: str
token_type: str
class fal_client.client.CDNTokenManager(key)

Bases: object

get_token()
Return type:

CDNToken

class fal_client.client.Completed(logs, metrics)

Bases: Status

Indicates the request has been completed and the result can be gathered. The logs field will contain the logs if the status operation was called with the with_logs parameter set to True. Metrics might contain the inference time, and other internal metadata (number of tokens processed, etc.).

logs: list[dict[str, Any]] | None
metrics: dict[str, Any]
exception fal_client.client.FalClientError

Bases: Exception

class fal_client.client.InProgress(logs)

Bases: Status

Indicates the request is currently being processed. If the status operation called with the with_logs parameter set to True, the logs field will be a list of log objects.

logs: list[dict[str, Any]] | None
class fal_client.client.Queued(position)

Bases: Status

Indicates the request is enqueued and waiting to be processed. The position field indicates the relative position in the queue (0-indexed).

position: int
class fal_client.client.Status

Bases: object

class fal_client.client.SyncClient(key=None, default_timeout=120.0)

Bases: object

cancel(application, request_id)
Return type:

None

default_timeout: float = 120.0
get_handle(application, request_id)
Return type:

SyncRequestHandle

key: str | None = None
result(application, request_id)
Return type:

Dict[str, Any]

run(application, arguments, *, path='', timeout=None, hint=None)

Run an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return the result of the inference call directly.

Return type:

Dict[str, Any]

status(application, request_id, *, with_logs=False)
Return type:

Status

stream(application, arguments, *, path='/stream', timeout=None)

Stream the output of an application with the given arguments (which will be JSON serialized). This is only supported at a few select applications at the moment, so be sure to first consult with the documentation of individual applications to see if this is supported.

The function will iterate over each event that is streamed from the server.

Return type:

Iterator[dict[str, Any]]

submit(application, arguments, *, path='', hint=None, webhook_url=None, priority=None)

Submit an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return a handle to the request that can be used to check the status and retrieve the result of the inference call when it is done.

Return type:

SyncRequestHandle

subscribe(application, arguments, *, path='', hint=None, with_logs=False, on_enqueue=None, on_queue_update=None, priority=None)
upload(data, content_type, file_name=None)

Upload the given data blob to the CDN and return the access URL. The content type should be specified as the second argument. Use upload_file or upload_image for convenience.

Return type:

str

upload_file(path)

Upload a file from the local filesystem to the CDN and return the access URL.

Return type:

str

upload_image(image, format='jpeg')

Upload a pillow image object to the CDN and return the access URL.

Return type:

str

class fal_client.client.SyncRequestHandle(request_id, response_url, status_url, cancel_url, client)

Bases: _BaseRequestHandle

cancel()

Cancel the request.

Return type:

None

client: Client
classmethod from_request_id(client, application, request_id)
Return type:

SyncRequestHandle

get()

Wait till the request is completed and return the result of the inference call.

Return type:

Dict[str, Any]

iter_events(*, with_logs=False, interval=0.1)

Continuously poll for the status of the request and yield it at each interval till the request is completed. If with_logs is True, logs will be included in the response.

Return type:

Iterator[Status]

status(*, with_logs=False)

Returns the status of the request (which can be one of the following: Queued, InProgress, Completed). If with_logs is True, logs will be included for InProgress and Completed statuses.

Return type:

Status

fal_client.client.encode(data, content_type)

Encode the given data blob to a data URL with the specified content type.

Return type:

str

fal_client.client.encode_file(path)

Encode a file from the local filesystem to a data URL with the inferred content type.

Return type:

str

fal_client.client.encode_image(image, format='jpeg')

Encode a pillow image object to a data URL with the specified format.

Return type:

str

Module contents

class fal_client.AsyncClient(key=None, default_timeout=120.0)

Bases: object

async cancel(application, request_id)
Return type:

None

default_timeout: float = 120.0
get_handle(application, request_id)
Return type:

AsyncRequestHandle

key: str | None = None
async result(application, request_id)
Return type:

Dict[str, Any]

async run(application, arguments, *, path='', timeout=None, hint=None)

Run an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return the result of the inference call directly.

Return type:

Dict[str, Any]

async status(application, request_id, *, with_logs=False)
Return type:

Status

async stream(application, arguments, *, path='/stream', timeout=None)

Stream the output of an application with the given arguments (which will be JSON serialized). This is only supported at a few select applications at the moment, so be sure to first consult with the documentation of individual applications to see if this is supported.

The function will iterate over each event that is streamed from the server.

Return type:

AsyncIterator[dict[str, Any]]

async submit(application, arguments, *, path='', hint=None, webhook_url=None, priority=None)

Submit an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return a handle to the request that can be used to check the status and retrieve the result of the inference call when it is done.

Return type:

AsyncRequestHandle

async subscribe(application, arguments, *, path='', hint=None, with_logs=False, on_enqueue=None, on_queue_update=None, priority=None)
async upload(data, content_type, file_name=None)

Upload the given data blob to the CDN and return the access URL. The content type should be specified as the second argument. Use upload_file or upload_image for convenience.

Return type:

str

async upload_file(path)

Upload a file from the local filesystem to the CDN and return the access URL.

Return type:

str

async upload_image(image, format='jpeg')

Upload a pillow image object to the CDN and return the access URL.

Return type:

str

class fal_client.AsyncRequestHandle(request_id, response_url, status_url, cancel_url, client)

Bases: _BaseRequestHandle

async cancel()

Cancel the request.

Return type:

None

cancel_url: str
client: AsyncClient
classmethod from_request_id(client, application, request_id)
Return type:

AsyncRequestHandle

async get()

Wait till the request is completed and return the result.

Return type:

Dict[str, Any]

async iter_events(*, with_logs=False, interval=0.1)

Continuously poll for the status of the request and yield it at each interval till the request is completed. If with_logs is True, logs will be included in the response.

Return type:

AsyncIterator[Status]

request_id: str
response_url: str
async status(*, with_logs=False)

Returns the status of the request (which can be one of the following: Queued, InProgress, Completed). If with_logs is True, logs will be included for InProgress and Completed statuses.

Return type:

Status

status_url: str
class fal_client.Completed(logs, metrics)

Bases: Status

Indicates the request has been completed and the result can be gathered. The logs field will contain the logs if the status operation was called with the with_logs parameter set to True. Metrics might contain the inference time, and other internal metadata (number of tokens processed, etc.).

logs: list[dict[str, Any]] | None
metrics: dict[str, Any]
class fal_client.InProgress(logs)

Bases: Status

Indicates the request is currently being processed. If the status operation called with the with_logs parameter set to True, the logs field will be a list of log objects.

logs: list[dict[str, Any]] | None
class fal_client.Queued(position)

Bases: Status

Indicates the request is enqueued and waiting to be processed. The position field indicates the relative position in the queue (0-indexed).

position: int
class fal_client.Status

Bases: object

class fal_client.SyncClient(key=None, default_timeout=120.0)

Bases: object

cancel(application, request_id)
Return type:

None

default_timeout: float = 120.0
get_handle(application, request_id)
Return type:

SyncRequestHandle

key: str | None = None
result(application, request_id)
Return type:

Dict[str, Any]

run(application, arguments, *, path='', timeout=None, hint=None)

Run an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return the result of the inference call directly.

Return type:

Dict[str, Any]

status(application, request_id, *, with_logs=False)
Return type:

Status

stream(application, arguments, *, path='/stream', timeout=None)

Stream the output of an application with the given arguments (which will be JSON serialized). This is only supported at a few select applications at the moment, so be sure to first consult with the documentation of individual applications to see if this is supported.

The function will iterate over each event that is streamed from the server.

Return type:

Iterator[dict[str, Any]]

submit(application, arguments, *, path='', hint=None, webhook_url=None, priority=None)

Submit an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return a handle to the request that can be used to check the status and retrieve the result of the inference call when it is done.

Return type:

SyncRequestHandle

subscribe(application, arguments, *, path='', hint=None, with_logs=False, on_enqueue=None, on_queue_update=None, priority=None)
upload(data, content_type, file_name=None)

Upload the given data blob to the CDN and return the access URL. The content type should be specified as the second argument. Use upload_file or upload_image for convenience.

Return type:

str

upload_file(path)

Upload a file from the local filesystem to the CDN and return the access URL.

Return type:

str

upload_image(image, format='jpeg')

Upload a pillow image object to the CDN and return the access URL.

Return type:

str

class fal_client.SyncRequestHandle(request_id, response_url, status_url, cancel_url, client)

Bases: _BaseRequestHandle

cancel()

Cancel the request.

Return type:

None

cancel_url: str
client: Client
classmethod from_request_id(client, application, request_id)
Return type:

SyncRequestHandle

get()

Wait till the request is completed and return the result of the inference call.

Return type:

Dict[str, Any]

iter_events(*, with_logs=False, interval=0.1)

Continuously poll for the status of the request and yield it at each interval till the request is completed. If with_logs is True, logs will be included in the response.

Return type:

Iterator[Status]

request_id: str
response_url: str
status(*, with_logs=False)

Returns the status of the request (which can be one of the following: Queued, InProgress, Completed). If with_logs is True, logs will be included for InProgress and Completed statuses.

Return type:

Status

status_url: str
fal_client.cancel(application, request_id)
Return type:

None

async fal_client.cancel_async(application, request_id)
Return type:

None

fal_client.encode(data, content_type)

Encode the given data blob to a data URL with the specified content type.

Return type:

str

fal_client.encode_file(path)

Encode a file from the local filesystem to a data URL with the inferred content type.

Return type:

str

fal_client.encode_image(image, format='jpeg')

Encode a pillow image object to a data URL with the specified format.

Return type:

str

fal_client.result(application, request_id)
Return type:

Dict[str, Any]

async fal_client.result_async(application, request_id)
Return type:

Dict[str, Any]

fal_client.run(application, arguments, *, path='', timeout=None, hint=None)

Run an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return the result of the inference call directly.

Return type:

Dict[str, Any]

async fal_client.run_async(application, arguments, *, path='', timeout=None, hint=None)

Run an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return the result of the inference call directly.

Return type:

Dict[str, Any]

fal_client.status(application, request_id, *, with_logs=False)
Return type:

Status

async fal_client.status_async(application, request_id, *, with_logs=False)
Return type:

Status

fal_client.stream(application, arguments, *, path='/stream', timeout=None)

Stream the output of an application with the given arguments (which will be JSON serialized). This is only supported at a few select applications at the moment, so be sure to first consult with the documentation of individual applications to see if this is supported.

The function will iterate over each event that is streamed from the server.

Return type:

Iterator[dict[str, Any]]

async fal_client.stream_async(application, arguments, *, path='/stream', timeout=None)

Stream the output of an application with the given arguments (which will be JSON serialized). This is only supported at a few select applications at the moment, so be sure to first consult with the documentation of individual applications to see if this is supported.

The function will iterate over each event that is streamed from the server.

Return type:

AsyncIterator[dict[str, Any]]

fal_client.submit(application, arguments, *, path='', hint=None, webhook_url=None, priority=None)

Submit an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return a handle to the request that can be used to check the status and retrieve the result of the inference call when it is done.

Return type:

SyncRequestHandle

async fal_client.submit_async(application, arguments, *, path='', hint=None, webhook_url=None, priority=None)

Submit an application with the given arguments (which will be JSON serialized). The path parameter can be used to specify a subpath when applicable. This method will return a handle to the request that can be used to check the status and retrieve the result of the inference call when it is done.

Return type:

AsyncRequestHandle

fal_client.subscribe(application, arguments, *, path='', hint=None, with_logs=False, on_enqueue=None, on_queue_update=None, priority=None)
async fal_client.subscribe_async(application, arguments, *, path='', hint=None, with_logs=False, on_enqueue=None, on_queue_update=None, priority=None)