API & development
Haiku 5.5 streaming
Handle Haiku 5.5 streaming as a lifecycle: ordered deltas, cancellation, incomplete output, final usage and recovery without duplicate requests.
Haiku 5.5 streaming lets an application display an answer while the response is still arriving. The difficult part is deciding what the interface may claim at each moment. Text on screen can be useful before it is complete, but a partially received answer should not acquire the same status as a finished, validated result.
This guide concerns a developer integration with Anthropic's documented event stream. It does not claim that every gateway forwards identical events, or that this website exposes a public streaming API. Start with a working non-streaming request, then add incremental delivery without changing the task's acceptance rules.
Give Haiku 5.5 streaming a state model
A useful interface distinguishes waiting, receiving, validating, completed, interrupted and failed. These are application states, not proposed provider event names. Waiting begins after your server accepts the operation; receiving begins when meaningful content arrives. Validation starts only after the provider supplies a complete response according to its protocol.
Keep the displayed text independent of that status. An interrupted answer can remain visible for inspection while clearly marked incomplete. Deleting it immediately makes diagnosis harder; quietly presenting it as completed is worse. Whether a user may copy the partial text is a product decision, but copying should not change the stored completion state.
For Haiku 5.5 streaming tasks with external consequences, add a separate approval stage after validation. A customer-support reply can be drafted incrementally, yet sending the reply should require a complete, policy-checked message. Streaming changes the delivery schedule, not the authority of the generated content.
Read events according to their scope
Anthropic's streaming reference describes a message envelope containing indexed content blocks. A block can start, receive deltas and stop before the overall message finishes. Message-level updates then carry completion information, and a terminal event closes the normal sequence. Error and keepalive events can also appear.
Prefer the official SDK's event handling or message accumulator over a parser built from arbitrary network chunks. A network read can split a character, an event field or a JSON document. Transport chunk boundaries are not semantic boundaries. Testing only with a fast local connection can conceal this distinction until a mobile connection fragments the response differently.
Associate deltas with the correct block index and type. Text, tool arguments and other supported content need different consumers. An application that appends every delta-like field to the visible answer may leak internal representation or produce malformed output. Unknown event types should be handled deliberately without being rendered as user prose.
Separate Haiku 5.5 streaming metrics
Measure time from accepted submission to the first useful text, and also time to the validated final result. A quick initial fragment can improve the feeling of responsiveness while the full answer remains slow. Reporting only the earliest byte obscures whether users actually finish their work sooner.
Record queue delay before the upstream request separately. When a busy application queues work for several seconds, replacing the model may not address the dominant delay. Likewise, measuring only inside the provider adapter misses authentication, input preparation and the time needed to save the final result.
Use a representative connection when testing Haiku 5.5 streaming. Slow the network, interrupt it and test a proxy that buffers data. A correct backend stream can appear non-streaming if an intermediary holds output until a threshold is reached. Inspect arrival timestamps rather than concluding that the model itself paused.
Render incrementally without exhausting the page
Avoid rebuilding the entire transcript on every tiny fragment. Buffer short bursts for rendering while preserving the underlying event order. The goal is readable progress, not one DOM update per token. Measure the effect on a long answer and a lower-powered device rather than judging only a short desktop demonstration.
Auto-scroll only while the reader is already following the newest content. When the reader scrolls upward, preserve that position and offer a way to return to the current answer. Otherwise a long stream repeatedly takes the page away from the passage the person is trying to inspect.
For Haiku 5.5 streaming accessibility, avoid announcing every character through a live region. Announce meaningful state changes and make the answer reachable through normal reading navigation. Keep the stop control keyboard-accessible, and do not move focus every time another paragraph appears. A moving answer should not become a moving interface.
Recover interrupted Haiku 5.5 streaming output
Suppose the connection ends after an answer lists two steps of a five-step procedure. You have useful partial text, but no evidence that the remaining instructions were received. Store an interrupted outcome and offer an explicit retry or continuation path appropriate to the task. Never infer completion from punctuation or a plausible final sentence.
A Haiku 5.5 streaming retry is a new attempt unless your provider documents a resumable mechanism for that request. Reconnecting the browser to your application's stored operation is different from asking the model to generate again. Name those actions differently in your design so users do not trigger a second paid generation while trying to recover the first view.
If the application supports reconnecting, retain ordered events or a durable accumulated result under an operation ID. Authenticate the reconnecting user before returning it. Do not place private response text in a public cache merely to make replay convenient. Retention and cleanup rules still apply to incomplete answers.
Reconcile usage once, after completion evidence
The provider documentation identifies cumulative usage counters in message updates. Do not add each cumulative output count as if it represented only the latest fragment. For example, observed totals of ten, twenty and thirty describe thirty output tokens at the last observation, not sixty. This arithmetic mistake can overcharge a user while every individual event looks valid.
Keep raw provider measurements and normalized accounting separate. A Haiku 5.5 streaming adapter should record which fields were present and whether final usage was received. If the stream breaks before that evidence arrives, preserve an unresolved state rather than inventing a precise count from visible characters.
Only one operation should settle the same application usage record. The stream handler, a reconnect request and a recovery worker may all observe completion, but they must not each deduct credits independently. A transactional terminal transition or equivalent idempotent settlement rule belongs in your application, outside the renderer.
Test Haiku 5.5 streaming with authored events
Build a small synthetic event sequence that produces a known answer. Replay it through the same accumulator your server uses. Then vary fragmentation without changing the semantic event sequence. The final answer should remain identical, and completion should occur only when the required terminal evidence is present.
| Fixture change | Application behavior to verify |
|---|---|
| Connection closes after visible text | Result remains incomplete |
| Non-text block precedes the answer | Only intended text appears in the answer |
| Usage counter grows across updates | Final cumulative amount is not summed repeatedly |
| Reader scrolls upward during delivery | View remains at the reader's position |
| Browser reconnects to an existing operation | No new provider call is started merely to display it |
These are proposed tests, not reported results for this website. Add an explicit error event after a successful HTTP connection, since a response that began with a successful status can still fail later. Also test cancellation during the waiting state, when there may be no visible text to explain what happened.
Decide when streaming is unnecessary
A short classification label often gains little from incremental display. A backend extraction job may care only about a validated final record. In those cases, streaming can still matter for transport constraints, but it does not automatically need to become a user-facing animation or a new interface mode.
Use Haiku 5.5 streaming where earlier visibility helps the reader act, inspect or stop an unwanted direction. For structured results, keep partial JSON separate from accepted records; the structured-output guide explains that boundary. The final test is whether the complete lifecycle remains understandable when the connection fails, not whether the happy path looks fast.