# `SuperPi.Event.Renderer.OpenAI`
[🔗](https://github.com/oleksandr/super-pi-beam/blob/v0.1.0/lib/super_pi/event/renderer/openai.ex#L1)

Renders events as OpenAI `chat.completion.chunk` maps for the Gateway's SSE stream.

- `text_delta` becomes `delta.content`.
- `thinking_delta` becomes `delta.reasoning_content`.
- `tool_started` and `tool_completed` become short progress lines in `delta.reasoning_content`, so
  a client shows tool use without the progress entering the answer text.
- `permission_request` becomes a `reasoning_content` line (a Gateway client cannot answer it, so
  `Permissions` fails closed and the tool call is blocked).

Every other event produces no chunk. The first chunk (role) and the closing chunks (stop, usage)
belong to the HTTP handler, which knows the usage totals.

Options: `:id`, `:created` (Unix seconds), `:model`.

# `finish_chunk`

```elixir
@spec finish_chunk(map(), String.t()) :: map()
```

A chunk with an empty delta and a `finish_reason`, for the handler's closing frame.

# `role_chunk`

```elixir
@spec role_chunk(map()) :: map()
```

The chunk that carries only the assistant role. The handler sends it first.

# `usage_chunk`

```elixir
@spec usage_chunk(map(), map()) :: map()
```

The usage chunk. It has no choices.

---

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