# `GenAI.Model.EncoderBehaviour`

# `completion`

```elixir
@type completion() :: any()
```

# `context`

```elixir
@type context() :: any()
```

# `headers`

```elixir
@type headers() :: list()
```

# `json`

```elixir
@type json() :: any()
```

# `message`

```elixir
@type message() :: any()
```

# `messages`

```elixir
@type messages() :: list()
```

# `method`

```elixir
@type method() :: :get | :post | :put | :delete | :option | :patch
```

# `model`

```elixir
@type model() :: any()
```

# `options`

```elixir
@type options() :: any()
```

# `request_body`

```elixir
@type request_body() :: any()
```

# `session`

```elixir
@type session() :: any()
```

# `settings`

```elixir
@type settings() :: map()
```

# `tool`

```elixir
@type tool() :: any()
```

# `tools`

```elixir
@type tools() :: list() | nil
```

# `uri`

```elixir
@type uri() :: url()
```

# `url`

```elixir
@type url() :: String.t()
```

# `completion_response`

```elixir
@callback completion_response(
  json(),
  model(),
  settings(),
  session(),
  context(),
  options()
) ::
  {:ok, completion()} | {:error, term()}
```

# `default_hyper_params`

```elixir
@callback default_hyper_params(model(), settings(), session(), context(), options()) ::
  {:ok, {settings(), session()}} | {:error, term()}
```

# `encode_message`

```elixir
@callback encode_message(message(), model(), session(), context(), options()) ::
  {:ok, {message(), session()}} | {:error, term()}
```

Format message for provider/model type.

# `encode_tool`

```elixir
@callback encode_tool(tool(), model(), session(), context(), options()) ::
  {:ok, {tool(), session()}} | {:error, term()}
```

Format tool for provider/model type.

# `endpoint`

```elixir
@callback endpoint(model(), settings(), session(), context(), options()) ::
  {:ok, {method(), uri()}}
  | {:ok, {{method(), uri()}, session()}}
  | {:error, term()}
```

Prepare endpoint and method to make inference call to

# `headers`

```elixir
@callback headers(model(), settings(), session(), context(), options()) ::
  {:ok, headers()} | {:ok, {headers(), session()}} | {:error, term()}
```

Prepare request headers

# `hyper_params`

```elixir
@callback hyper_params(model(), settings(), session(), context(), options()) ::
  {:ok, {settings(), session()}} | {:error, term()}
```

Obtain list of hyper params supported by given model including mapping and conditional rules/alterations

# `normalize_messages`

```elixir
@callback normalize_messages(messages(), model(), session(), context(), options()) ::
  {:ok, {any(), any()}} | {:error, any()}
```

# `request_body`

```elixir
@callback request_body(
  model(),
  messages(),
  tools(),
  settings(),
  session(),
  context(),
  options()
) ::
  {:ok, headers()} | {:ok, {headers(), session()}} | {:error, term()}
```

Prepare request body to be passed to inference call.

# `with_dynamic_setting`

```elixir
@callback with_dynamic_setting(
  body :: term(),
  setting :: term(),
  model :: term(),
  settings :: term()
) ::
  term()
```

Set setting with dynamic model based logic.

# `with_dynamic_setting`

```elixir
@callback with_dynamic_setting(
  body :: term(),
  setting :: term(),
  model :: term(),
  settings :: term(),
  default :: term()
) :: term()
```

# `with_dynamic_setting_as`

```elixir
@callback with_dynamic_setting_as(
  body :: term(),
  as_setting :: term(),
  setting :: term(),
  model :: term(),
  settings :: term()
) :: term()
```

Set setting as_setting with dynamic model based logic.

# `with_dynamic_setting_as`

```elixir
@callback with_dynamic_setting_as(
  body :: term(),
  as_setting :: term(),
  setting :: term(),
  model :: term(),
  settings :: term(),
  default :: term()
) :: term()
```

---

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