BerriAI/litellm · error · ValueError
PG Vector API key is required. Set PG_VECTOR_API_KEY environ
Error message
PG Vector API key is required. Set PG_VECTOR_API_KEY environment variable or pass api_key in litellm_params.
What it means
Credential guard in the PG Vector store config's validate_environment: the API key lookup (litellm_params.api_key then PG_VECTOR_API_KEY secret) returned nothing, so authentication headers for the deployed PG vector service cannot be built.
Source
Thrown at litellm/llms/pg_vector/vector_stores/transformation.py:40
You just need to connect litellm proxy to this deployed server.
Requires:
- api_base: The base URL for the PG vector service
- api_key: API key for authentication with the PG vector service
"""
def validate_environment(self, headers: dict, litellm_params: GenericLiteLLMParams | None) -> dict:
"""
Validate environment and set headers for PG vector service authentication
"""
litellm_params = litellm_params or GenericLiteLLMParams()
# Get API key from various sources
api_key: Final = litellm_params.api_key or get_secret_str("PG_VECTOR_API_KEY")
if not api_key:
raise ValueError(
"PG Vector API key is required. Set PG_VECTOR_API_KEY environment variable or pass api_key in litellm_params."
)
headers.update(
{
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
}
)
return headers
def get_complete_url(
self,
api_base: str | None,
litellm_params: dict,
) -> str:
"""View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set the PG_VECTOR_API_KEY environment variable before making the call.
- Pass api_key in litellm_params for the pg_vector vector store.
Example fix
os.environ["PG_VECTOR_API_KEY"] = "<key>" # or litellm.vector_stores.create(..., api_key="<key>")
Defensive patterns
Strategy: validation
When it happens
Trigger: Triggered when calling a PG Vector vector store without an API key: PG_VECTOR_API_KEY env var unset and no api_key passed in litellm_params.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/393840692c557280.
Report an issue: GitHub.