Packages

AgentSea gateway: strategy-based routing, circuit breaking, and failover across LLM providers.

Current section

Files

Jump to
agentsea_gateway lib agent_sea gateway router cost_optimized.ex
Raw

lib/agent_sea/gateway/router/cost_optimized.ex

defmodule AgentSea.Gateway.Router.CostOptimized do
@moduledoc "Orders candidates cheapest-model-first using `AgentSea.ModelPricing`."
@behaviour AgentSea.Gateway.Router
@impl true
def order(candidates, _ctx) do
Enum.sort_by(candidates, &AgentSea.ModelPricing.weight(&1.model))
end
end