# `Wardrik.Setup`

Builds `%Wardrik{}` from `Wardrik.start_link/1`'s options, and each agent's options.

# `agent`

```elixir
@spec agent(Wardrik.t(), keyword()) :: keyword()
```

Returns the options `WardrikCore.start_agent/2` takes for the agent `opts` describe.

Adds Wardrik's events, prices, credentials and keys, spending, middleware and policies. The
agent's own `:policy` is held alongside Wardrik's.

# `policies`

```elixir
@spec policies(WardrikPolicy.t() | [WardrikPolicy.t()] | keyword() | map() | nil) :: [
  WardrikPolicy.t()
]
```

Returns an agent's `:policy` as a list of policies. `nil` is `[]`.

# `policy`

```elixir
@spec policy(WardrikPolicy.t() | keyword() | map() | nil) :: WardrikPolicy.t() | nil
```

Builds a policy from its rules. Returns a `WardrikPolicy` or `nil` as given.

# `price`

```elixir
@spec price(String.t(), keyword()) :: WardrikCore.Usage.price()
```

Returns the price of the model `spec`, in US dollars per million tokens.

    # Its own rates
    Wardrik.Setup.price("acme:model-1", input: 0.5, output: 1.5)

    # Another model's catalog price, 10% more
    Wardrik.Setup.price("zai_coding_plan:glm-5.1", priced_as: "zai:glm-5.1", markup: 0.1)

## Options

  * `:input` and `:output` - rates. Both required unless `:priced_as` is set.
  * `:cache_read` and `:cache_write` - optional rates.
  * `:priced_as` - a model whose catalog price to use. Can't be combined with rates.
  * `:markup` - added on top, as `0.1` for 10%. `0` unless set.

Raises `ArgumentError` if the price is invalid.

# `wardrik`

```elixir
@spec wardrik(keyword()) :: Wardrik.t()
```

Builds a `%Wardrik{}` from `Wardrik.start_link/1`'s options.

---

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