Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Whitelist anthropic and bedrock models (#76768)

applebyb7262df2172f
diff --git a/src/metabase/metabot/self/bedrock.clj b/src/metabase/metabot/self/bedrock.clj
index 94b6e70ed46..462f6c80e9e 100644
--- a/src/metabase/metabot/self/bedrock.clj
+++ b/src/metabase/metabot/self/bedrock.clj
@@ -180,30 +180,44 @@
(catch Exception e
(core/rethrow-api-error! "bedrock" bedrock-error-msg e))))
+(def ^:private supported-models
+ "Bedrock models offered in the Metabot model picker, as a map of model id -> display name.
+ `list-models` returns the intersection of this map with the mantle `/v1/models` catalog.
+ Excludes `openai.gpt-oss*`, which are not invokable through the mantle `/openai/v1` routes."
+ {"anthropic.claude-fable-5" "Claude Fable 5"
+ "anthropic.claude-opus-4-8" "Claude Opus 4.8"
+ "anthropic.claude-opus-4-7" "Claude Opus 4.7"
+ "anthropic.claude-sonnet-5" "Claude Sonnet 5"
+ "anthropic.claude-haiku-4-5" "Claude Haiku 4.5"
+ "openai.gpt-5.4" "GPT-5.4"
+ "openai.gpt-5.4-2026-03-05" "GPT-5.4 (2026-03-05)"
+ "openai.gpt-5.5" "GPT-5.5"
+ "openai.gpt-5.5-2026-04-23" "GPT-5.5 (2026-04-23)"})
+
(defn- supported-model?
- "Whether a catalog model is supported by this adapter: Anthropic and OpenAI models only.
- Excludes `anthropic.*fable*` pending further testing.
- Excludes `openai.gpt-oss*`, which appear in the catalog but are not invokable through the mantle /openai/v1 routes."
+ "Whether a `/v1/models` catalog entry is one of the [[supported-models]]."
[{:keys [id]}]
- (boolean
- (and id
- (or (and (str/starts-with? id "anthropic.")
- (not (str/includes? id "fable")))
- (and (str/starts-with? id "openai.")
- (not (str/starts-with? id "openai.gpt-oss")))))))
+ (contains? supported-models id))
+
+(defn- available-model?
+ "Whether a `/v1/models` catalog entry is available.
+ The AWS catalog lists models the account cannot invoke with `:status \"unavailable\"`, e.g. claude-fable-5 when the
+ account's data retention mode doesn't satisfy the model's `:data_retention` requirement."
+ [{:keys [status]}]
+ (= status "available"))
(defn list-models
- "List the Bedrock models supported by this adapter (see [[supported-model?]]).
+ "List the Bedrock models supported by this adapter (see [[supported-models]]).
No-arg uses the `llm-bedrock-*` settings. The opts map supports `:credentials`, a map of `:access-key-id`,
`:secret-access-key`, `:region`, and (for temporary credentials) `:session-token`, plus `:ai-proxy?`,
which is not supported for Bedrock and throws when true."
([] (list-models {}))
([opts]
{:models (->> (list-all-models opts)
- (filter supported-model?)
+ (filter (every-pred supported-model? available-model?))
(sort-by :id)
(mapv (fn [{:keys [id]}]
- {:id id :display_name id})))}))
+ {:id id :display_name (supported-models id)})))}))
;;; --------------------------------------------- API family dispatch -------------------------------------------
diff --git a/src/metabase/metabot/self/claude.clj b/src/metabase/metabot/self/claude.clj
index 54401743e25..b3a4cd8ac63 100644
--- a/src/metabase/metabot/self/claude.clj
+++ b/src/metabase/metabot/self/claude.clj
@@ -289,28 +289,55 @@
529 (tru "Anthropic API is overloaded and is asking us to wait")
(tru "Anthropic API error (HTTP {0})" status))))
+(def ^:private supported-models
+ "Anthropic chat models offered in the Metabot model picker, as a map of model id -> display name.
+ `list-models` returns the intersection of this map with the account's `/v1/models` catalog."
+ {"claude-fable-5" "Claude Fable 5"
+ "claude-opus-4-8" "Claude Opus 4.8"
+ "claude-opus-4-7" "Claude Opus 4.7"
+ "claude-opus-4-6" "Claude Opus 4.6"
+ "claude-opus-4-5-20251101" "Claude Opus 4.5"
+ "claude-opus-4-1-20250805" "Claude Opus 4.1"
+ "claude-sonnet-5" "Claude Sonnet 5"
+ "claude-sonnet-4-6" "Claude Sonnet 4.6"
+ "claude-sonnet-4-5-20250929" "Claude Sonnet 4.5"
+ "claude-haiku-4-5-20251001" "Claude Haiku 4.5"})
+
+(defn- supported-model?
+ "Whether a `/v1/models` catalog entry is one of the [[supported-models]]."
+ [{:keys [id]}]
+ (contains? supported-models id))
+
+(defn- list-all-models
+ "Fetch the full Anthropic model catalog (`GET /v1/models`).
+ No-arg uses the configured API key. Opts map supports `:credentials` (`{:api-key ...}`) and `:ai-proxy?`."
+ [{:keys [credentials ai-proxy?]}]
+ (when (and credentials (str/blank? (:api-key credentials)))
+ (throw (core/missing-api-key-ex "Anthropic")))
+ (try
+ (let [auth (core/resolve-auth "anthropic" "Anthropic"
+ (when-let [k (or (not-empty (:api-key credentials))
+ (not-empty (llm/llm-anthropic-api-key)))]
+ {:url (llm/llm-anthropic-api-base-url)
+ :headers {"x-api-key" k}})
+ ai-proxy?)
+ res (core/request auth {:method :get
+ :url "/v1/models"
+ :headers {"anthropic-version" "2023-06-01"}})]
+ (:data (json/decode+kw (:body res))))
+ (catch Exception e
+ (core/rethrow-api-error! "anthropic" anthropic-error-msg e))))
+
(defn list-models
- "List available Anthropic models.
+ "List the Anthropic chat models supported by this adapter (see [[supported-models]]).
No-arg uses the configured API key. Opts map supports `:credentials` (`{:api-key ...}`) and `:ai-proxy?`."
([] (list-models {}))
- ([{:keys [credentials ai-proxy?]}]
- (when (and credentials (str/blank? (:api-key credentials)))
- (throw (core/missing-api-key-ex "Anthropic")))
- (try
- (let [auth (core/resolve-auth "anthropic" "Anthropic"
- (when-let [k (or (not-empty (:api-key credentials))
- (not-empty (llm/llm-anthropic-api-key)))]
- {:url (llm/llm-anthropic-api-base-url)
- :headers {"x-api-key" k}})
- ai-proxy?)
- res (core/request auth {:method :get
- :url "/v1/models"
- :headers {"anthropic-version" "2023-06-01"}})
- body (json/decode+kw (:body res))
- models (reverse (sort-by :created_at (:data body)))]
- {:models (map #(select-keys % [:id :display_name]) models)})
- (catch Exception e
- (core/rethrow-api-error! "anthropic" anthropic-error-msg e)))))
+ ([opts]
+ {:models (->> (list-all-models opts)
+ (filter supported-model?)
+ (sort-by :id)
+ (mapv (fn [{:keys [id display_name]}]
+ {:id id :display_name (or display_name (supported-models id))})))}))
(defn- model-supports-temperature?
"Whether `model` accepts an explicit `temperature` parameter.
diff --git a/src/metabase/metabot/self/openai.clj b/src/metabase/metabot/self/openai.clj
index e9add7c3aab..ecf2dc58e1f 100644
--- a/src/metabase/metabot/self/openai.clj
+++ b/src/metabase/metabot/self/openai.clj
@@ -199,14 +199,14 @@
(tru "OpenAI API error (HTTP {0})" status))))
(def ^:private supported-models
- "OpenAI chat models offered in the Metabot model picker.
- `list-models` returns the intersection of this set with the account's `/v1/models` catalog."
- #{"gpt-5.5"
- "gpt-5.5-pro"
- "gpt-5.4"
- "gpt-5.4-pro"
- "gpt-5.4-mini"
- "gpt-5"})
+ "OpenAI chat models offered in the Metabot model picker, as a map of model id -> display name.
+ `list-models` returns the intersection of this map with the account's `/v1/models` catalog."
+ {"gpt-5.5" "GPT-5.5"
+ "gpt-5.5-pro" "GPT-5.5 Pro"
+ "gpt-5.4" "GPT-5.4"
+ "gpt-5.4-pro" "GPT-5.4 Pro"
+ "gpt-5.4-mini" "GPT-5.4 Mini"
+ "gpt-5" "GPT-5"})
(defn- supported-model?
"Whether a `/v1/models` catalog entry is one of the [[supported-models]]."
@@ -246,7 +246,7 @@
(filter supported-model?)
(sort-by :id)
(mapv (fn [{:keys [id]}]
- {:id id :display_name id})))}))
+ {:id id :display_name (supported-models id)})))}))
(defn- model-supports-temperature?
"Whether `model` accepts an explicit `temperature` parameter.
diff --git a/test/metabase/metabot/self/bedrock_test.clj b/test/metabase/metabot/self/bedrock_test.clj
index be0d5220fa1..577bd189628 100644
--- a/test/metabase/metabot/self/bedrock_test.clj
+++ b/test/metabase/metabot/self/bedrock_test.clj
@@ -17,22 +17,50 @@
;;; ──────────────────────────────────────────────────────────────────
(def ^:private fake-catalog
- [{:id "qwen.qwen3-next-80b-a3b-instruct" :object "model"}
- {:id "openai.gpt-5.5" :object "model"}
- {:id "anthropic.claude-haiku-4-5" :object "model"}
- {:id "openai.gpt-oss-120b" :object "model"}
- {:id "deepseek.v3.2" :object "model"}
- {:id "anthropic.claude-opus-4-8" :object "model"}
- {:id "anthropic.claude-fable-5" :object "model"}
- {:id "openai.gpt-5.4" :object "model"}])
+ [{:id "qwen.qwen3-next-80b-a3b-instruct" :object "model" :status "available"}
+ {:id "openai.gpt-5.5" :object "model" :status "available"}
+ {:id "anthropic.claude-haiku-4-5" :object "model" :status "available"}
+ {:id "openai.gpt-oss-120b" :object "model" :status "available"}
+ {:id "deepseek.v3.2" :object "model" :status "available"}
+ {:id "anthropic.claude-opus-4-8" :object "model" :status "available"}
+ {:id "anthropic.claude-fable-5" :object "model" :status "available"}
+ {:id "anthropic.claude-3-5-sonnet" :object "model" :status "available"}
+ {:id "openai.gpt-5.4" :object "model" :status "available"}])
-(deftest list-models-filters-to-supported-vendors-test
+(deftest ^:parallel supported-model?-test
+ (testing "whitelisted models are supported"
+ (doseq [id ["anthropic.claude-fable-5" "anthropic.claude-opus-4-8" "anthropic.claude-sonnet-5" "openai.gpt-5.5"]]
+ (is (true? (#'bedrock/supported-model? {:id id})) id)))
+ (testing "non-whitelisted models are not supported, even for supported vendors"
+ (doseq [id ["anthropic.claude-3-5-sonnet" "openai.gpt-oss-120b"
+ "qwen.qwen3-next-80b-a3b-instruct" "deepseek.v3.2"]]
+ (is (false? (#'bedrock/supported-model? {:id id})) id))))
+
+(deftest list-models-filters-to-whitelist-test
(mt/with-dynamic-fn-redefs [bedrock/list-all-models (constantly fake-catalog)]
- (testing "only anthropic.* and openai.* models survive, gpt-oss and fable excluded, sorted by id"
- (is (= {:models [{:id "anthropic.claude-haiku-4-5" :display_name "anthropic.claude-haiku-4-5"}
- {:id "anthropic.claude-opus-4-8" :display_name "anthropic.claude-opus-4-8"}
- {:id "openai.gpt-5.4" :display_name "openai.gpt-5.4"}
- {:id "openai.gpt-5.5" :display_name "openai.gpt-5.5"}]}
+ (testing "only whitelisted models survive sorted by id"
+ (is (= {:models [{:id "anthropic.claude-fable-5" :display_name "Claude Fable 5"}
+ {:id "anthropic.claude-haiku-4-5" :display_name "Claude Haiku 4.5"}
+ {:id "anthropic.claude-opus-4-8" :display_name "Claude Opus 4.8"}
+ {:id "openai.gpt-5.4" :display_name "GPT-5.4"}
+ {:id "openai.gpt-5.5" :display_name "GPT-5.5"}]}
+ (bedrock/list-models))))))
+
+(deftest list-models-filters-unavailable-models-test
+ (mt/with-dynamic-fn-redefs
+ [bedrock/list-all-models
+ (constantly
+ [{:id "anthropic.claude-fable-5"
+ :object "model"
+ :status "unavailable"
+ :status_reason "This model is not available under data retention mode 'default'."
+ :data_retention {:allowed_modes ["provider_data_share"] :mode "default" :source "model_default"}}
+ {:id "anthropic.claude-sonnet-5"
+ :object "model"
+ :status "available"
+ :data_retention {:allowed_modes ["default" "provider_data_share" "none"] :mode "default" :source "model_default"}}])]
+ (testing "whitelisted models whose catalog status is not \"available\" are excluded"
+ (is (= {:models [{:id "anthropic.claude-sonnet-5" :display_name "Claude Sonnet 5"}]}
(bedrock/list-models))))))
(deftest list-models-missing-credentials-test
@@ -57,7 +85,8 @@
(testing "credentials passed in opts are used without requiring saved settings"
(let [captured (atom nil)]
(with-redefs [http/request (fn [req] (reset! captured req) {:body {:data fake-catalog}})]
- (is (=? {:models [{:id "anthropic.claude-haiku-4-5"}
+ (is (=? {:models [{:id "anthropic.claude-fable-5"}
+ {:id "anthropic.claude-haiku-4-5"}
{:id "anthropic.claude-opus-4-8"}
{:id "openai.gpt-5.4"}
{:id "openai.gpt-5.5"}]}
diff --git a/test/metabase/metabot/self/claude_test.clj b/test/metabase/metabot/self/claude_test.clj
index 602cd000d9c..c9da018a615 100644
--- a/test/metabase/metabot/self/claude_test.clj
+++ b/test/metabase/metabot/self/claude_test.clj
@@ -449,6 +449,28 @@
#"No Anthropic API key is set"
(claude/list-models {}))))))))))
+(deftest ^:parallel supported-model?-test
+ (testing "whitelisted models are supported"
+ (doseq [id ["claude-fable-5" "claude-opus-4-8" "claude-sonnet-5" "claude-haiku-4-5-20251001"]]
+ (is (true? (#'claude/supported-model? {:id id})) id)))
+ (testing "non-whitelisted models are not supported"
+ (doseq [id ["claude-3-5-sonnet-20241022" "claude-opus-4-0" "claude-sonnet-4-20250514"]]
+ (is (false? (#'claude/supported-model? {:id id})) id))))
+
+(deftest list-models-filters-catalog-to-whitelist-test
+ (testing "list-models keeps only whitelisted models sorted by id, preserving display_name"
+ (mt/with-temporary-setting-values [llm.settings/llm-anthropic-api-key "sk-ant-byok"]
+ (with-redefs [http/request (fn [_]
+ {:body (json/encode
+ {:data [{:id "claude-sonnet-5" :display_name "Claude Sonnet 5" :created_at "2026-01-01"}
+ {:id "claude-opus-4-8" :display_name "Claude Opus 4.8" :created_at "2026-02-01"}
+ {:id "claude-3-5-sonnet-20241022" :display_name "Claude 3.5" :created_at "2024-10-22"}
+ {:id "claude-fable-5" :display_name "Claude Fable 5" :created_at "2026-03-01"}]})})]
+ (is (= [{:id "claude-fable-5" :display_name "Claude Fable 5"}
+ {:id "claude-opus-4-8" :display_name "Claude Opus 4.8"}
+ {:id "claude-sonnet-5" :display_name "Claude Sonnet 5"}]
+ (:models (claude/list-models))))))))
+
;;; ──────────────────────────────────────────────────────────────────
;;; temperature support tests
;;; ──────────────────────────────────────────────────────────────────
diff --git a/test/metabase/metabot/self/openai_test.clj b/test/metabase/metabot/self/openai_test.clj
index 9e20767f1f6..dc9f22edcea 100644
--- a/test/metabase/metabot/self/openai_test.clj
+++ b/test/metabase/metabot/self/openai_test.clj
@@ -280,8 +280,8 @@
{:id "o3" :created 15}
{:id "text-embedding-3-small" :created 8}
{:id "whisper-1" :created 7}]}})]
- (is (= [{:id "gpt-5" :display_name "gpt-5"}
- {:id "gpt-5.4" :display_name "gpt-5.4"}]
+ (is (= [{:id "gpt-5" :display_name "GPT-5"}
+ {:id "gpt-5.4" :display_name "GPT-5.4"}]
(:models (openai/list-models))))))))
;;; ──────────────────────────────────────────────────────────────────