Class: Braintrust::Internal::ApiKeyResolver
- Inherits:
-
Object
- Object
- Braintrust::Internal::ApiKeyResolver
- Defined in:
- lib/braintrust/internal/api_key_resolver.rb
Overview
Resolves the Braintrust API key from explicit options, ENV, or the nearest .braintrust.json file without mutating the process environment.
Constant Summary collapse
- ENV_KEY =
"BRAINTRUST_API_KEY"- CONFIG_FILE =
".braintrust.json"- SEARCH_PARENT_LIMIT =
64
Class Method Summary collapse
Class Method Details
.resolve(explicit_api_key: nil, start_dir: Dir.pwd) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/braintrust/internal/api_key_resolver.rb', line 14 def self.resolve(explicit_api_key: nil, start_dir: Dir.pwd) return explicit_api_key unless explicit_api_key.nil? env_api_key = ENV[ENV_KEY] return env_api_key if env_api_key && !env_api_key.strip.empty? find_file_api_key(start_dir) end |