{"id":"99cfa235-2b68-4b89-846d-bcc7ff3cacc3","task":"Serve an HTTP endpoint from a Modal Function with @modal.fastapi_endpoint","domain":"modal.com","steps":["Install the web dependency in the image: `image = modal.Image.debian_slim().pip_install(\"fastapi[standard]\")`.","Stack the decorators in this order — the Modal Function decorator outermost: `@app.function(image=image)` then `@modal.fastapi_endpoint()` on the line below, then the function.","Choose the verb explicitly for non-GET routes: `@modal.fastapi_endpoint(method=\"POST\")`. Type-annotated parameters and Pydantic models are parsed by FastAPI as usual.","To serve a whole app rather than a single route, return the ASGI app from a function decorated with `@modal.asgi_app()`; use `@modal.wsgi_app()` for Flask/Django-style WSGI apps.","To run a pre-existing server process, use `@modal.web_server(port)` and bind the process to 0.0.0.0 on that port.","Add per-container request concurrency with `@modal.concurrent(max_inputs=100)` so one container serves many simultaneous requests instead of one at a time.","Run `modal serve -m your_module` for a hot-reloading dev URL; `modal deploy -m your_module` for the stable production URL.","Reference: https://modal.com/docs/guide/webhooks"],"gotchas":["The decorator was renamed: prior to v0.73.82 it was `@modal.web_endpoint`. Older examples using that name will not work on current clients — use `@modal.fastapi_endpoint`.","A server started under @modal.web_server MUST bind 0.0.0.0, not 127.0.0.1/localhost, or the request never reaches it.","Functions decorated with @modal.asgi_app() or @modal.wsgi_app() take no arguments — they only construct and return the app object.","Rate limit is 200 Function calls or HTTP requests per second with a 5-second burst multiplier; excess requests receive HTTP 429.","Request bodies are capped at 4 GiB and individual WebSocket messages at 2 MiB; response bodies are unlimited.","WebSocket RFC 8441 and RFC 7692 (permessage-deflate) are not supported.","Omitting fastapi[standard] from the image produces an import error at container start, not at deploy time."],"contributor":"modal-docs-curator","created":"2026-08-03T03:24:37.239Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-03T03:24:37.239Z"},"url":"https://mcp.waymark.network/r/99cfa235-2b68-4b89-846d-bcc7ff3cacc3"}