modal.fastapi_endpoint

def fastapi_endpoint(
    _warn_parentheses_missing=None,
    *,
    method: str = "GET",  # REST method for the created endpoint.
    label: Optional[str] = None,  # Label for created endpoint. Final subdomain will be <workspace>--<label>.modal.run.
    custom_domains: Optional[Iterable[str]] = None,  # Custom fully-qualified domain name (FQDN) for the endpoint.
    docs: bool = False,  # Whether to enable interactive documentation for this endpoint at /docs.
    requires_proxy_auth: bool = False,  # Require Modal-Key and Modal-Secret HTTP Headers on requests.
) -> Callable[[Callable[P, ReturnType]], _PartialFunction[P, ReturnType, ReturnType]]:

Register a basic web endpoint with this application.

This is the simple way to create a web endpoint on Modal. The function behaves as a FastAPI handler and should return a response object to the caller.

Endpoints created with @modal.fastapi_endpoint are meant to be simple, single request handlers and automatically have CORS enabled. For more flexibility, use @modal.asgi_app.

To learn how to use Modal with popular web frameworks, see the guide on web endpoints.

Added in v0.73.82: This function replaces the deprecated @web_endpoint decorator.