Streaming & task results
Practical guidance for using NeonAPI.
Streaming responses
For supported text endpoints, stream: true requests events instead of one final JSON response. Chat Completions, Responses, Anthropic and Gemini use different event formats. Use a compatible SDK or parser for the selected protocol.
Keep incomplete chunks in a buffer. Network chunk boundaries do not necessarily match event boundaries or UTF-8 character boundaries. Handle completion, cancellation and errors explicitly.
Asynchronous video and image tasks
Some models return a task ID first. Save that ID, poll the documented task endpoint at a reasonable interval, and retrieve the result only after completion. Do not create a new task just to check the previous one.
Downloads and expiry
Result URLs can expire or require authentication. Fetch the result using the documented route and permitted credentials; do not treat a temporary result URL as permanent storage.
Disconnects and retries
A timeout or closed connection does not necessarily cancel work already accepted by the upstream. Check the task state or usage logs before resubmitting to avoid duplicate work and charges.