# `Omni.Dialects.OpenAICompletions`
[🔗](https://github.com/aaronrussell/omni/blob/v2.0.0/lib/omni/dialects/openai_completions.ex#L1)

Dialect implementation for the OpenAI Chat Completions wire format.

See `Omni.Dialect.Text` for the behaviour specification and delta types.

## Compat flags

The Chat Completions format is spoken by many providers, most with small
deviations from OpenAI's own API. With no flags, the dialect behaves
exactly like OpenAI's API; each flag describes one deviation. Set them on
a provider's endpoint for this dialect,
`dialects: %{Omni.Dialects.OpenAICompletions => [compat: [...]]}` (see
`Omni.Provider`).

| Flag | Default (OpenAI) | Setting it |
|---|---|---|
| `:max_tokens_field` | `"max_completion_tokens"` | sends `:max_tokens` under this field |
| `:thinking_effort_field` | `"reasoning_effort"` | sends the effort level here (dots nest: `"reasoning.effort"`) |
| `:thinking_budget_field` | no budget sent | sends a token budget here, for models that take one and list no effort values |
| `:thinking_replay_format` | earlier reasoning not sent back | how reasoning is sent back on assistant messages (below) |
| `:thinking_toggle_format` | off is `reasoning_effort: "none"`; no on-switch | how thinking is switched on and off (below) |
| `:output_format` | `:json_schema` | `:json_object`: JSON mode, with the schema in the system prompt |
| `:attachment_format` | `:file` | `:file_url`: non-image files as `file_url` content parts |
| `:omit` | `[]` | never sends these: `:cache`, `:thinking`, `:strict_schema` |
| `:extra_body` | `%{}` | merges these literal fields into every request body |

`:thinking_toggle_format` values:

- `:thinking_type` - `thinking: {type: "enabled" | "disabled"}`
- `:enable_thinking` - `enable_thinking: true | false`
- `:reasoning_enabled` - `reasoning: {enabled: true | false}`

`:thinking_replay_format` values:

- `:none` - reasoning is not sent back
- `:reasoning_content` - sends the message's thinking text in a
  `reasoning_content` field on that assistant message
- `:reasoning` - the same, in a `reasoning` field
- `:reasoning_details` - captures `reasoning_details` from responses and
  sends them back on that assistant message; streamed fragments are
  merged into one entry per reasoning block when the stream completes
- `:content_chunks` - sends the message's thinking as one leading
  `{type: "thinking", thinking: [{type: "text", ...}]}` part of a
  `content` array, before its text parts

Models that list effort values (see `Omni.Model`) take the effort, even
when a toggle format is set; the toggle switches them off, and switches on
models without effort values. Likewise a budget is sent only to models
without effort values.

---

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