Run a text model and stream the answer
Text models only. Applies the same validation, quota, pricing and hold as createTask, then keeps the connection open and returns the model answer as a Server-Sent Events stream. Each event is a data: line carrying one JSON chunk; the stream ends with data: [DONE].
The hold is settled when the stream completes. If generation fails within the first few seconds, before anything has been sent, the response is a normal JSON error and the hold is released. While a long reasoning model has not produced anything yet, and whenever the stream goes quiet, the connection carries SSE comment lines (: keep-alive) so the network edge does not close it as idle; clients must ignore them, as the SSE format requires. A failure after that point, or mid-stream, ends the stream with an error event and the hold is still released — a truncated answer is never charged as a completed one. The reverse also holds: when the model has already finished the answer (every choice has a finish_reason and the final usage has arrived) and only then reports an error or drops the connection, the answer is complete, the stream ends with [DONE] as usual, and the delivered usage is charged.
Non-streaming calls to the compatible endpoints are kept open too. A call that finishes within about 30 seconds is answered exactly as before. A longer one commits a 200 response with Content-Type: application/json and the X-Spicy-Keepalive: 1 header after about 30 seconds, then sends a newline every 15 seconds until the answer is ready; JSON allows leading whitespace, so standard parsers read the body unchanged. Because the status is already sent, a failure after that point arrives as the protocol's own error object in the body of the 200 response, with the same code and message it would otherwise have had, and the hold is still released. The whitespace is not model output: disconnecting after it follows the usual disconnect rules, and an answer that ends up empty or refused is still refunded.
Generation models (image, video, audio) are asynchronous and must use createTask with recordInfo polling; calling this endpoint for them returns 503.
Request
- Base URL: https://api.spicyapi.ai
- URL: https://api.spicyapi.ai/api/v1/jobs/stream
- Auth: HTTP bearer
Headers
Stable key for one logical task submission; retained for 24 hours per account and bound to both the submitting API key and normalized request fingerprint. A sibling key receives 409 without the original task ID.
Retention for this one task, in whole seconds. It applies to both the generated outputs and the stored request text. The effective value is always min(header, account setting, platform maximum): a request can only shorten retention, never extend it. 0 is valid and means the outputs are removed as soon as the task reaches a terminal state. Values that cannot be applied never fail the request: a negative number is clamped to 0, a value above the ceiling is clamped to the ceiling, and a value that is not a decimal integer is ignored so the account setting applies. The effective result is always reported back in retention on the task record. Accepted by createTask and stream. retry inherits the source task's effective value and ignores this header, so one task family never ends up with two different expiry times. quote does not accept it because it does not create a task.
Request body
Response
Server-Sent Events stream of the model answer.
Changes
No recorded changes to this operation across all 1 revision of this API.