- Control HTTP status codes.
- Use server-sent events (SSEs) for streaming responses.
You can return a response from predict or postprocess, but not both.
Returning Custom Response Objects
Any subclass of starlette.responses.Response is supported.If
predict
returns a response, postprocess
cannot be used.Example: Streaming with SSEs
For server-sent events (SSEs), useStreamingResponse
:
Limitations
- Response headers are not fully propagated – include metadata in the response body.
Also see Using Request Objects
for handling raw requests.