Class: ActionAgent::ProviderKey
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActionAgent::ProviderKey
- Includes:
- Ownable
- Defined in:
- app/models/action_agent/provider_key.rb
Overview
Per-account LLM provider credential (Settings -> Provider API Keys). Generation runs (AgentExecutionService and the evaluation LLM judge) prefer these over the platform's ENV-configured keys, so users can run agents with their own OpenAI/Anthropic/OpenRouter accounts — or point ollama at their own host (e.g. a tunnel to a locally running instance).
The credential is encrypted at rest with Active Record Encryption. API keys are never rendered back to the client — only a masked hint; ollama hosts are not secret and are shown in full (see #display_hint).
Constant Summary collapse
- KEY_PROVIDERS =
Providers that authenticate with an API key.
%w[openai anthropic openrouter].freeze
- HOST_PROVIDERS =
Providers addressed by host URL instead of a key.
%w[ollama].freeze
- PROVIDERS =
(KEY_PROVIDERS + HOST_PROVIDERS).freeze
Constants included from Ownable
Instance Method Summary collapse
-
#display_hint ⇒ Object
"sk-a…Q2z9" for keys; hosts are shown in full.
-
#generation_options ⇒ Object
Options merged into generate_with for runs owned by this key's owner, overriding the host app's config/active_agent.yml credentials.
- #host_based? ⇒ Boolean
Methods included from Ownable
Methods inherited from ApplicationRecord
Instance Method Details
#display_hint ⇒ Object
"sk-a…Q2z9" for keys; hosts are shown in full.
44 45 46 47 48 |
# File 'app/models/action_agent/provider_key.rb', line 44 def display_hint return credential if host_based? "#{credential.first(4)}…#{credential.last(4)}" end |
#generation_options ⇒ Object
Options merged into generate_with for runs owned by this key's owner, overriding the host app's config/active_agent.yml credentials.
39 40 41 |
# File 'app/models/action_agent/provider_key.rb', line 39 def host_based? ? { host: credential } : { access_token: credential } end |
#host_based? ⇒ Boolean
33 34 35 |
# File 'app/models/action_agent/provider_key.rb', line 33 def host_based? HOST_PROVIDERS.include?(provider) end |