-
-
Notifications
You must be signed in to change notification settings - Fork 125
Closed
Labels
BugSomething isn't workingSomething isn't workingPlatformIssues & PRs about the AI Platform componentIssues & PRs about the AI Platform componentStatus: Needs Review
Description
It appears that the OpenRouter streaming returns the result as SSE. As a result, json_decode does not work with non-JSON payloads.
This is the code that I used
$response = new StreamedResponse();
// $agent platform is open router
$response->setChunks($agent->call($messages, ['stream' => true])->getContent());
$response->headers->set('Content-Type', 'text/event-stream');
$response->headers->set('Cache-Control', 'no-cache');
$response->headers->set('Connection', 'keep-alive');
$response->headers->set('X-Accel-Buffering', 'no');Uncaught Symfony\Component\HttpClient\Exception\JsonException: Syntax error for "https://openrouter.ai/api/v1/chat/completions". in /app/vendor/symfony/http-client/Response/CommonResponseTrait.php:90
The response
: OPENROUTER PROCESSING
: OPENROUTER PROCESSING
data: {"id":"gen-1763615146-iIx4toyMERHwoHbPtVnN","provider":"Google AI Studio","model":"google/gemini-2.5-flash","object":"chat.completion.chunk","created":1763615146,"choices":[{"index":0,"delta":{"role":"assistant","content":"...","reasoning":null,"reasoning_details":[]},"finish_reason":null,"native_finish_reason":null,"logprobs":null}]}
data: {"id":"gen-1763615146-iIx4toyMERHwoHbPtVnN","provider":"Google AI Studio","model":"google/gemini-2.5-flash","object":"chat.completion.chunk","created":1763615146,"choices":[{"index":0,"delta":{"role":"assistant","content":"......","reasoning":null,"reasoning_details":[]},"finish_reason":null,"native_finish_reason":null,"logprobs":null}]}
data: {"id":"gen-1763615146-iIx4toyMERHwoHbPtVnN","provider":"Google AI Studio","model":"google/gemini-2.5-flash","object":"chat.completion.chunk","created":1763615146,"choices":[{"index":0,"delta":{"role":"assistant","content":".........","reasoning":null,"reasoning_details":[]},"finish_reason":null,"native_finish_reason":null,"logprobs":null}]}
data: {"id":"gen-1763615146-iIx4toyMERHwoHbPtVnN","provider":"Google AI Studio","model":"google/gemini-2.5-flash","object":"chat.completion.chunk","created":1763615146,"choices":[{"index":0,"delta":{"role":"assistant","content":"............","reasoning":null,"reasoning_details":[]},"finish_reason":null,"native_finish_reason":null,"logprobs":null}]}
data: [DONE]
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't workingPlatformIssues & PRs about the AI Platform componentIssues & PRs about the AI Platform componentStatus: Needs Review