vllm.envs ¶
VLLM_SKIP_MODEL_NAME_VALIDATION module-attribute ¶
VLLM_SKIP_MODEL_NAME_VALIDATION: bool = False
If set, vLLM will skip model name validation in API requests. This allows any model name to be accepted in the 'model' field of requests, making the server model-name agnostic. Useful for proxy/gateway scenarios.
__getattr__ ¶
__getattr__(name: str)
Gets environment variables lazily.
NOTE: After enable_envs_cache() invocation (which triggered after service initialization), all environment variables will be cached.
Source code in vllm/envs.py
_resolve_rust_frontend_path ¶
_resolve_rust_frontend_path() -> str | None
Resolve the Rust frontend binary path.
Returns None if VLLM_USE_RUST_FRONTEND is not enabled. When enabled, resolves VLLM_RUST_FRONTEND_PATH ("auto" by default) to the actual binary path.
Source code in vllm/envs.py
compile_factors ¶
Return env vars used for torch.compile cache keys.
Start with every known vLLM env var; drop entries in ignored_factors; hash everything else. This keeps the cache key aligned across workers.
Source code in vllm/envs.py
1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 | |
disable_envs_cache ¶
Resets the environment variables cache. It could be used to isolate environments between unit tests.
Source code in vllm/envs.py
enable_envs_cache ¶
Enables caching of environment variables. This is useful for performance reasons, as it avoids the need to re-evaluate environment variables on every call.
NOTE: Currently, it's invoked after service initialization to reduce runtime overhead. This also means that environment variables should NOT be updated after the service is initialized.
Source code in vllm/envs.py
env_list_with_choices ¶
env_list_with_choices(
env_name: str,
default: list[str],
choices: list[str] | Callable[[], list[str]],
case_sensitive: bool = True,
) -> Callable[[], list[str]]
Create a lambda that validates environment variable containing comma-separated values against allowed choices
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_name | str | Name of the environment variable | required |
default | list[str] | Default list of values if not set | required |
choices | list[str] | Callable[[], list[str]] | List of valid string options or callable that returns list | required |
case_sensitive | bool | Whether validation should be case sensitive | True |
Returns:
| Type | Description |
|---|---|
Callable[[], list[str]] | Lambda function for environment_variables |
Callable[[], list[str]] | dict that returns list of strings |
Source code in vllm/envs.py
env_set_with_choices ¶
env_set_with_choices(
env_name: str,
default: list[str],
choices: list[str] | Callable[[], list[str]],
case_sensitive: bool = True,
) -> Callable[[], set[str]]
Creates a lambda which that validates environment variable containing comma-separated values against allowed choices which returns choices as a set.
Source code in vllm/envs.py
env_with_choices ¶
env_with_choices(
env_name: str,
default: str | None,
choices: list[str] | Callable[[], list[str]],
case_sensitive: bool = True,
) -> Callable[[], str | None]
Create a lambda that validates environment variable against allowed choices
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_name | str | Name of the environment variable | required |
default | str | None | Default value if not set (can be None) | required |
choices | list[str] | Callable[[], list[str]] | List of valid string options or callable that returns list | required |
case_sensitive | bool | Whether validation should be case sensitive | True |
Returns:
| Type | Description |
|---|---|
Callable[[], str | None] | Lambda function for environment_variables dict |
Source code in vllm/envs.py
get_env_or_set_default ¶
Create a lambda that returns an environment variable value if set, or generates and sets a default value using the provided factory function.
Source code in vllm/envs.py
get_vllm_port ¶
get_vllm_port() -> int | None
Get the port from VLLM_PORT environment variable.
Returns:
| Type | Description |
|---|---|
int | None | The port number as an integer if VLLM_PORT is set, None otherwise. |
Raises:
| Type | Description |
|---|---|
ValueError | If VLLM_PORT is a URI, suggest k8s service discovery issue. |