From 13aa367c8a71dc5f31d9fe85153c7ccdd3c5b414 Mon Sep 17 00:00:00 2001 From: Matthew Farrellee Date: Mon, 30 Jun 2025 21:08:44 -0400 Subject: [PATCH] fix: default api_key from env must be a SecretStr (#2565) # What does this PR do? fixes the api_key type when read from env ## Test Plan run nvidia template w/o api_key in run.yaml and perform inference before change the inference will fail w/ - ``` File ".../llama-stack/llama_stack/providers/remote/inference/nvidia/nvidia.py", line 118, in _get_client_for_base_url api_key=(self._config.api_key.get_secret_value() if self._config.api_key else "NO KEY"), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'get_secret_value' ``` --- llama_stack/providers/remote/inference/nvidia/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama_stack/providers/remote/inference/nvidia/config.py b/llama_stack/providers/remote/inference/nvidia/config.py index 6369928bb..0f45269c8 100644 --- a/llama_stack/providers/remote/inference/nvidia/config.py +++ b/llama_stack/providers/remote/inference/nvidia/config.py @@ -40,7 +40,7 @@ class NVIDIAConfig(BaseModel): description="A base url for accessing the NVIDIA NIM", ) api_key: SecretStr | None = Field( - default_factory=lambda: os.getenv("NVIDIA_API_KEY"), + default_factory=lambda: SecretStr(os.getenv("NVIDIA_API_KEY")), description="The NVIDIA API key, only needed of using the hosted service", ) timeout: int = Field(