i want to use steaming protocol in django,but have some problem
Description
I want to use the streaming protocol in the AI SDK, but my backend is Django instead of the FastAPI provided in the sample. After testing, I found that when using Django's streamHttpResponse to return data, the front-end sample cannot obtain the streaming data in real time. Instead, it waits for all the data to be transmitted completely before displaying them all together on the interface. What should I do? `` @api_view(['GET']) def test_get1(request): def event_stream(): for i in range(10):
yield '{{"data":{text}}}\n\n'.format(text=json.dumps(i))
yield 'data:'+json.dumps(i) + '\n\n' sleep(1) response = StreamingHttpResponse(event_stream(),content_type='text/event-stream') response.headers['x-vercel-ai-data-stream'] = 'v1' return response
AI SDK Version
No response
got same error here
I created an open-source Python library that handles the AI SDK streaming protocol and SSE event ordering for Python backends.
It may help for this issue/use case.
Identify issue type
Identified type: None
Confidence: High
Rationale: This is primarily a support/integration question about implementing streaming with Django, not a confirmed bug in the AI SDK or a request to change documentation/examples/product behavior.
Evidence:
- Reporter asks how to use the AI SDK streaming protocol with a Django backend instead of the FastAPI sample.
- The described problem is that Django StreamingHttpResponse output is buffered until complete, with a request for guidance: “What should I do?”
- Comments only echo the same issue or suggest a third-party Python library; they do not identify a concrete AI SDK defect.