# `Alloy.Provider.OpenAIStream`
[🔗](https://github.com/alloy-ex/alloy/blob/v0.10.1/lib/alloy/provider/openai_stream.ex#L1)

Shared OpenAI-format SSE stream parser.

Used by all OpenAI-compatible providers (OpenAI, DeepSeek, Mistral,
OpenRouter, xAI, Ollama). Each provider calls `stream/5` with its
own URL and headers; this module handles SSE parsing and response
normalization.

## OpenAI Streaming Format

    data: {"choices":[{"index":0,"delta":{"content":"chunk"}}]}
    data: {"choices":[{"index":0,"delta":{"tool_calls":[...]}}]}
    data: [DONE]

Text deltas are emitted via `on_chunk`. Tool call argument deltas
are accumulated silently. The final response has the same shape as
`complete/3`.

# `stream`

```elixir
@spec stream(
  String.t(),
  [{String.t(), String.t()}],
  map(),
  (String.t() -&gt; :ok),
  keyword()
) ::
  {:ok, Alloy.Provider.completion_response()} | {:error, term()}
```

Execute a streaming request against an OpenAI-compatible endpoint.

Returns `{:ok, completion_response()} | {:error, term()}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
