ask-llm-providers 0.8.4 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab26881afbb5870a65101d2118505e38bf9193e60d929cc40ec7be4bc6808ca8
4
- data.tar.gz: b403d02544b5dc14d31c148f4a43bc78137214ce88045351dba030dc0d8707c4
3
+ metadata.gz: 211eb4cd29010d57e87c742adea03ee891fedcea11b55f1c9e1ef9674dbdeeee
4
+ data.tar.gz: da4a556126e2c2beb180b560e0045a71f689195599649b16ba3ede4e8cb6dac0
5
5
  SHA512:
6
- metadata.gz: 314a2930f8b7cc6940b17ff51c3c7fb834829b305bd275e99787408981ebbcfa9ceeb5b05984af8876131040c695bfa02dc5d7bfe3b8ffb4d97a62cfcec1cc54
7
- data.tar.gz: 0e251210f83fd64485cc29350232abcdda64dde3b73be765301f69ddfc5251dc32043d3e1c483c11691e8ce53662a8598e7554ec699c37b7ac9c896378bd7327
6
+ metadata.gz: 9f81cd0be9fe948bc4e01c263f24698037b3b3a9aedda82fda53d874cc314603f02f02f9820081a5c99c22ca0a6a521df38c12dd21c82125aaf11f3eb7c76d21
7
+ data.tar.gz: 4eb6a604ef5564e4ba722620fd47d1603876746810e4f3442ae53c2368fb983ea43dd0690d086ac99ee7cae5bd5c2a11ffcff432c803b715ad61941b6a3f6b13
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.8.5] — 2026-07-18
2
+
3
+ ### Fixed
4
+
5
+ - **`OpenAICompatible#normalize_compat_config` now resolves credentials from `api_key_env` via `Ask::Auth`** — Previously the method only checked explicit config keys and environment variables. Now it also calls `Ask::Auth.resolve` using the downcased `api_key_env` name (e.g., `OPENCODE_API_KEY` → `:opencode_api_key` → resolves through Rails credentials at `opencode.api_key`, env, file, database, or OAuth). This fixes credential resolution for all 26 OpenAI-compatible providers when the API key is stored in Rails credentials, the ask credentials file, or any provider in the auth chain — not just environment variables.
6
+
1
7
  ## [0.8.4] — 2026-07-18
2
8
 
3
9
  ### Fixed
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module LLM
5
- VERSION = "0.8.4"
5
+ VERSION = "0.8.6"
6
6
  end
7
7
  end
@@ -79,7 +79,8 @@ module Ask
79
79
  config[:"#{slug}_api_key"] ||
80
80
  ENV[@compat_cfg[:api_key_env].to_s] ||
81
81
  (ENV[@compat_cfg[:alternate_env].to_s] if @compat_cfg[:alternate_env]) ||
82
- ENV["#{slug.upcase}_API_KEY"]
82
+ ENV["#{slug.upcase}_API_KEY"] ||
83
+ resolve_credential_from_env_name
83
84
 
84
85
  base_url = config[:base_url] || config["base_url"] ||
85
86
  ENV["#{slug.upcase}_API_BASE"] ||
@@ -87,6 +88,38 @@ module Ask
87
88
 
88
89
  Ask::LLM::Config.new(api_key:, base_url:)
89
90
  end
91
+
92
+ # Uses the registry's +api_key_env+ as a credential name for
93
+ # Ask::Auth.resolve. This lets users store their API key under the
94
+ # canonical credential name (e.g., +opencode.api_key+ in Rails
95
+ # credentials) while using a specific variant provider
96
+ # (e.g., +opencode_go+) whose slug differs from the base name.
97
+ #
98
+ # For +opencode_go+ with +api_key_env: "OPENCODE_API_KEY"+,
99
+ # this resolves +:opencode_api_key+, which checks:
100
+ # ENV["OPENCODE_API_KEY"] →
101
+ # Rails.application.credentials.opencode.api_key
102
+ #
103
+ # @return [String, nil]
104
+ def resolve_credential_from_env_name
105
+ env_name = @compat_cfg[:api_key_env]
106
+ return nil unless env_name
107
+
108
+ s = env_name.to_s
109
+ # Try as a flat key (e.g., :opencode_api_key)
110
+ # and as a nested path by keeping the parent portion before _API_KEY
111
+ # as the first segment and :api_key as the second (e.g., [:opencode, :api_key])
112
+ flat = s.downcase.to_sym
113
+ nested = nil
114
+ if s.end_with?("_API_KEY")
115
+ parent = s.delete_suffix("_API_KEY").downcase
116
+ nested = [parent.to_sym, :api_key] unless parent.empty?
117
+ end
118
+
119
+ Ask::Auth.resolve(flat, nested)
120
+ rescue StandardError
121
+ nil
122
+ end
90
123
  end
91
124
  end
92
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-llm-providers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto