This commit is contained in:
Ashwin Bharambe 2025-10-27 13:00:59 -07:00
parent 7c73997b50
commit 04294ff092
2 changed files with 2 additions and 22 deletions

View file

@ -16,7 +16,7 @@ NVIDIA inference provider for accessing NVIDIA NIM models and AI services.
|-------|------|----------|---------|-------------|
| `allowed_models` | `list[str \| None` | No | | List of models that should be registered with the model registry. If None, all models are allowed. |
| `refresh_models` | `<class 'bool'>` | No | False | Whether to refresh models periodically from the provider |
| `api_key` | `pydantic.types.SecretStr \| None` | No | | The NVIDIA API key, only needed of using the hosted service |
| `api_key` | `pydantic.types.SecretStr \| None` | No | | Authentication credential for the provider |
| `url` | `<class 'str'>` | No | https://integrate.api.nvidia.com | A base url for accessing the NVIDIA NIM |
| `timeout` | `<class 'int'>` | No | 60 | Timeout for the HTTP requests |
| `append_api_version` | `<class 'bool'>` | No | True | When set to false, the API version will not be appended to the base_url. By default, it is true. |

View file

@ -7,7 +7,7 @@
import os
from typing import Any
from pydantic import BaseModel, Field, SecretStr, field_validator
from pydantic import BaseModel, Field
from llama_stack.providers.utils.inference.model_registry import RemoteInferenceProviderConfig
from llama_stack.schema_utils import json_schema_type
@ -47,10 +47,6 @@ class NVIDIAConfig(RemoteInferenceProviderConfig):
default_factory=lambda: os.getenv("NVIDIA_BASE_URL", "https://integrate.api.nvidia.com"),
description="A base url for accessing the NVIDIA NIM",
)
api_key: SecretStr | None = Field(
default=None,
description="The NVIDIA API key, only needed of using the hosted service",
)
timeout: int = Field(
default=60,
description="Timeout for the HTTP requests",
@ -60,22 +56,6 @@ class NVIDIAConfig(RemoteInferenceProviderConfig):
description="When set to false, the API version will not be appended to the base_url. By default, it is true.",
)
@field_validator("api_key", mode="before")
@classmethod
def _default_api_key_from_env(cls, value: SecretStr | str | None) -> SecretStr | None:
"""Populate the API key from the NVIDIA_API_KEY environment variable when absent."""
if value is None:
env_value = os.getenv("NVIDIA_API_KEY")
return SecretStr(env_value) if env_value else None
if isinstance(value, SecretStr):
return value
if isinstance(value, str):
return SecretStr(value)
return value
@classmethod
def sample_run_config(
cls,