VanaAPI

← Writing

The first words arrive before the answer is ready

Wire formatsEN2026-10-28

You ask an AI assistant a question. A moment later, words begin appearing, even though the answer is still being written. That gradual arrival is a streaming response. Your application receives pieces of the output and can display them without waiting for the complete answer.

Server-sent events, usually shortened to SSE, are a common way to carry those pieces over an HTTP connection. Understanding a few details makes streaming easier to build and less confusing to troubleshoot.

§ A response that stays open

With a non-streaming request, your application usually waits for the server to finish preparing an answer before receiving the complete response. With streaming, the server sends response headers, keeps the response open, and delivers additional data as it becomes available.

SSE gives that data a simple text format. The response uses the content type text/event-stream. Events contain fields such as data:, and a blank line separates one event from the next. Some APIs also use an event: field to identify the kind of update being sent.

The direction matters: SSE carries updates from the server to the client. Your application sends the original prompt in its request, then reads the response stream. It does not send new chat messages back through that same response.

§ Small pieces need a little assembly

A streamed AI answer often arrives as incremental updates called deltas. One update might contain part of a word, several words, or no visible text at all. There is no reliable rule that one event equals one token or one sentence.

Your application collects the text updates in order and appends them to the answer already on screen. It should also recognize metadata, tool-related updates, errors, and completion signals instead of treating every event as text to display.

Network chunks are another boundary to keep separate. A single read from the connection may contain several SSE events, or only part of one. An SDK or SSE parser handles that buffering so your application can work with complete events.

§ Choosing streaming in an SDK

For an OpenAI-compatible chat request, streaming is commonly enabled with stream: true. Instead of receiving one finished response object, your program iterates over incoming updates. Exact fields and completion signals depend on the API and endpoint.

Vana API provides an OpenAI-compatible endpoint at https://api.vanaapi.com and also supports the Anthropic Messages and Gemini native protocols. You can use an OpenAI SDK with its compatible interface, keeping your stream-handling code aligned with the interface you choose.

The distinction is useful when changing integrations: the shared idea is incremental delivery, but each protocol has its own event structure. Code written to read one structure should not assume another will match.

§ Making partial answers feel dependable

Streaming reduces the wait before the reader sees something useful. It does not guarantee that the complete answer will finish sooner. For a beginner’s application, a few clear behaviors matter more than elaborate visual effects.

  • Show a waiting state until the first text arrives, then keep the growing answer visible.
  • Mark the answer as complete only after the protocol’s completion signal.
  • If the connection fails early, label the answer as interrupted and preserve the text already received.
  • Offer a stop control and cancel the underlying request when the user activates it.

A connection closing is not always proof of success. Likewise, retrying an interrupted generation may produce a fresh answer rather than resume the old one. Browser EventSource supports reconnection, but many AI requests use POST through an SDK or fetch, so automatic resumption should never be assumed.

§ A small first experiment

Start with a short prompt, display incoming text, and record whether the stream finishes normally. Then test an interrupted connection. If you run through a backend or proxy, check that it forwards updates promptly; buffering can make a streaming response appear all at once.

Create a Vana API account to try this with a supported SDK. Usage is billed per real token with no monthly fee. Streaming changes when the output reaches your application; the underlying work remains a token-based request.