{"record":{"id":"393840692c557280","repo":"BerriAI/litellm","slug":"pg-vector-api-key-is-required-set-pg-vector-api-k","errorCode":null,"errorMessage":"PG Vector API key is required. Set PG_VECTOR_API_KEY environment variable or pass api_key in litellm_params.","messagePattern":"PG Vector API key is required\\. Set PG_VECTOR_API_KEY environment variable or pass api_key in litellm_params\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/pg_vector/vector_stores/transformation.py","lineNumber":40,"sourceCode":"\n    You just need to connect litellm proxy to this deployed server.\n\n    Requires:\n    - api_base: The base URL for the PG vector service\n    - api_key: API key for authentication with the PG vector service\n    \"\"\"\n\n    def validate_environment(self, headers: dict, litellm_params: GenericLiteLLMParams | None) -> dict:\n        \"\"\"\n        Validate environment and set headers for PG vector service authentication\n        \"\"\"\n        litellm_params = litellm_params or GenericLiteLLMParams()\n\n        # Get API key from various sources\n        api_key: Final = litellm_params.api_key or get_secret_str(\"PG_VECTOR_API_KEY\")\n\n        if not api_key:\n            raise ValueError(\n                \"PG Vector API key is required. Set PG_VECTOR_API_KEY environment variable or pass api_key in litellm_params.\"\n            )\n\n        headers.update(\n            {\n                \"Authorization\": f\"Bearer {api_key}\",\n                \"Content-Type\": \"application/json\",\n            }\n        )\n\n        return headers\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        litellm_params: dict,\n    ) -> str:\n        \"\"\"","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/pg_vector/vector_stores/transformation.py#L22-L58","documentation":"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.","triggerScenarios":"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.","commonSituations":"See trigger scenarios.","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."],"exampleFix":"os.environ[\"PG_VECTOR_API_KEY\"] = \"<key>\"  # or litellm.vector_stores.create(..., api_key=\"<key>\")","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}