Class: ActiveAgent::Providers::OpenRouter::Requests::ProviderPreferences

Inherits:
Common::BaseModel
  • Object
show all
Defined in:
lib/active_agent/providers/open_router/requests/provider_preferences.rb

Overview

Provider preferences for routing requests to specific providers

Controls how OpenRouter selects and routes requests to underlying model providers. Enables filtering by parameters, cost constraints, privacy settings, and provider-specific preferences.

Examples:

Basic provider routing

prefs = ProviderPreferences.new(
  require_parameters: true,
  allow_fallbacks: false
)

Privacy-focused routing

prefs = ProviderPreferences.new(
  data_collection: 'deny',
  zdr: true
)

Cost-optimized routing

prefs = ProviderPreferences.new(
  sort: 'price',
  max_price: { prompt: 0.01, completion: 0.03 }
)

Provider ordering

prefs = ProviderPreferences.new(
  order: ['OpenAI', 'Anthropic'],
  ignore: ['Together']
)

See Also:

Instance Attribute Summary collapse

Method Summary

Methods inherited from Common::BaseModel

#<=>, #==, attribute, #deep_compact, #deep_dup, delegate_attributes, drop_attributes, inherited, #initialize, #inspect, keys, #merge!, required_attributes, #serialize, #to_h, #to_hash

Constructor Details

This class inherits a constructor from ActiveAgent::Providers::Common::BaseModel

Instance Attribute Details

#allow_fallbacksBoolean?

Returns whether to allow backup providers when primary is unavailable

  • true: (default) use next best provider when primary unavailable

  • false: only use primary/custom provider, return error if unavailable.

Returns:

  • (Boolean, nil)

    whether to allow backup providers when primary is unavailable

    • true: (default) use next best provider when primary unavailable

    • false: only use primary/custom provider, return error if unavailable



46
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 46

attribute :allow_fallbacks, :boolean

#data_collectionString?

Returns data collection preference

  • ‘allow’: (default) allow providers which store/train on user data

  • ‘deny’: only use providers that don’t collect user data.

Returns:

  • (String, nil)

    data collection preference

    • ‘allow’: (default) allow providers which store/train on user data

    • ‘deny’: only use providers that don’t collect user data



58
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 58

attribute :data_collection, :string

#ignoreArray<String>

Returns blocklist of provider slugs (merged with account settings).

Returns:

  • (Array<String>)

    blocklist of provider slugs (merged with account settings)



74
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 74

attribute :ignore, default: -> { [] }

#max_priceMaxPrice?

Returns maximum price constraints per token/operation.

Returns:

  • (MaxPrice, nil)

    maximum price constraints per token/operation



89
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 89

attribute :max_price, MaxPriceType.new

#onlyArray<String>

Returns allowlist of provider slugs (merged with account settings).

Returns:

  • (Array<String>)

    allowlist of provider slugs (merged with account settings)



70
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 70

attribute :only, default: -> { [] }

#orderArray<String>

Returns ordered list of provider slugs to try in sequence.

Returns:

  • (Array<String>)

    ordered list of provider slugs to try in sequence



66
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 66

attribute :order, default: -> { [] }

#quantizationsArray<String>

Returns quantization levels to filter providers by Options: int4, int8, fp4, fp6, fp8, fp16, bf16, fp32, unknown.

Returns:

  • (Array<String>)

    quantization levels to filter providers by Options: int4, int8, fp4, fp6, fp8, fp16, bf16, fp32, unknown



79
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 79

attribute :quantizations, default: -> { [] }

#require_parametersBoolean?

Returns whether to filter to providers supporting all parameters

  • true: only use providers that support all provided parameters

  • false: providers receive only the parameters they support.

Returns:

  • (Boolean, nil)

    whether to filter to providers supporting all parameters

    • true: only use providers that support all provided parameters

    • false: providers receive only the parameters they support



52
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 52

attribute :require_parameters, :boolean

#sortString?

Returns sorting strategy when order not specified Options: price, throughput, latency Note: disables load balancing when set.

Returns:

  • (String, nil)

    sorting strategy when order not specified Options: price, throughput, latency Note: disables load balancing when set



85
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 85

attribute :sort, :string

#zdrBoolean?

Returns zero data retention mode (stricter privacy).

Returns:

  • (Boolean, nil)

    zero data retention mode (stricter privacy)



62
# File 'lib/active_agent/providers/open_router/requests/provider_preferences.rb', line 62

attribute :zdr, :boolean