LLMProxy.Limit (llm_proxy v0.1.0)

Copy Markdown View Source

Usage limit for API keys.

Summary

Types

metric()

@type metric() ::
  :requests
  | :cache_write_tokens
  | :cache_read_tokens
  | :output_tokens
  | :input_tokens
  | :cost_usd

t()

@type t() :: %LLMProxy.Limit{max: number(), metric: metric(), window: window()}

window()

@type window() :: :month | :week | :day | :four_hours | :hour | :minute

Functions

cache_read_tokens(window, max)

@spec cache_read_tokens(window(), non_neg_integer()) :: t()

cache_write_tokens(window, max)

@spec cache_write_tokens(window(), non_neg_integer()) :: t()

check(arg1)

@spec check(map()) :: :ok | {:error, String.t()}

cost(window, max)

@spec cost(window(), number()) :: t()

input_tokens(window, max)

@spec input_tokens(window(), non_neg_integer()) :: t()

new(metric, window, max)

@spec new(metric(), window(), number()) :: t()

normalize(limits)

@spec normalize(term()) :: {:ok, [t()]} | {:error, String.t()}

output_tokens(window, max)

@spec output_tokens(window(), non_neg_integer()) :: t()

requests(window, max)

@spec requests(window(), non_neg_integer()) :: t()

valid?(limits)

@spec valid?(term()) :: boolean()