# `LlamaCppEx.ChatCompletion`
[🔗](https://github.com/nyo16/llama_cpp_ex/blob/main/lib/llama_cpp_ex/chat_completion.ex#L1)

OpenAI-compatible chat completion response struct.

Mirrors the shape of `POST /v1/chat/completions` responses.

# `choice`

```elixir
@type choice() :: %{
  index: integer(),
  message: %{
    :role =&gt; String.t(),
    :content =&gt; String.t() | nil,
    :reasoning_content =&gt; String.t() | nil,
    optional(:tool_calls) =&gt; [tool_call()]
  },
  finish_reason: String.t()
}
```

# `t`

```elixir
@type t() :: %LlamaCppEx.ChatCompletion{
  choices: [choice()],
  created: integer(),
  id: String.t(),
  model: String.t(),
  object: String.t(),
  usage: usage()
}
```

# `tool_call`

```elixir
@type tool_call() :: %{
  id: String.t(),
  type: String.t(),
  function: %{name: String.t(), arguments: String.t()}
}
```

A tool call, present on `message` only when the reply called a tool (see the
`:tools` option of `LlamaCppEx.chat_completion/3`). `arguments` is JSON text,
as in the OpenAI API.

# `usage`

```elixir
@type usage() :: %{
  prompt_tokens: integer(),
  completion_tokens: integer(),
  total_tokens: integer()
}
```

---

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