I was running into a “method not allowed” when using stream and upon inspection I realised the API does not adhere to what I thought was the SSE spec by using a “POST” method for the server-sent events endpoint mode. Now after some digging, the actual methods valid for SSE are not defined in the spec, though the EventSource
constructor on the browser side implicitly uses a GET method and according to both the spec and MDN, there’s no way to change this.
While I’m not using the browser to communicate with Perplexity, the library I chose for an SSE client also follows this pattern by only allowing the GET method for initiating the event stream, which of course 1. does not work with Perplexity due to “method not allowed” and 2. does not permit a request body so even if it worked, there would be no way to specify the “stream” option or the prompt anyway.
So it seems like a bug, even the docs doesn’t use EventSource (it seems to use some proxy for API calls) for the playground/request tester, it couldn’t due to this limitation and from what I can see, it doesn’t stream the response anyway.
For now I can write my own SSE client implementation that does use POST but, while the spec doesn’t explicitly require a GET request, this seems like an issue that at least goes against convention of current implementations of SSE.