{"record":{"id":"815195ce02ad39fa","repo":"BerriAI/litellm","slug":"vertex-project-and-vertex-location-are-required-fo","errorCode":null,"errorMessage":"vertex_project and vertex_location are required for Vertex AI","messagePattern":"vertex_project and vertex_location are required for Vertex AI","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/image_edit/vertex_gemini_transformation.py","lineNumber":140,"sourceCode":"        Get the complete URL for Vertex AI Gemini generateContent API\n        \"\"\"\n        # Use the model name as provided, handling vertex_ai prefix\n        model_name = model\n        if model.startswith(\"vertex_ai/\"):\n            model_name = model.replace(\"vertex_ai/\", \"\")\n\n        # If a custom api_base is provided, use it directly\n        # This allows users to use proxies or mock endpoints\n        if api_base:\n            return api_base.rstrip(\"/\")\n\n        # First check litellm_params (where vertex_ai_project/vertex_ai_location are passed)\n        # then fall back to environment variables and other sources\n        vertex_project: Final = self.safe_get_vertex_ai_project(litellm_params) or self._resolve_vertex_project()\n        vertex_location: Final = self.safe_get_vertex_ai_location(litellm_params) or self._resolve_vertex_location()\n\n        if not vertex_project or not vertex_location:\n            raise ValueError(\"vertex_project and vertex_location are required for Vertex AI\")\n\n        base_url: Final = get_vertex_base_url(vertex_location)\n\n        return f\"{base_url}/v1/projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/{model_name}:generateContent\"\n\n    def transform_image_edit_request(\n        self,\n        model: str,\n        prompt: str | None,\n        image: FileTypes | None,\n        image_edit_optional_request_params: dict[str, Any],\n        litellm_params: GenericLiteLLMParams,\n        headers: dict,\n    ) -> tuple[dict[str, Any], RequestFiles | None]:\n        inline_parts: Final = self._prepare_inline_image_parts(image) if image else []\n        if not inline_parts:\n            raise ValueError(\"Vertex AI Gemini image edit requires at least one image.\")\n","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/image_edit/vertex_gemini_transformation.py#L122-L158","documentation":"Vertex AI Gemini image edit builds its endpoint URL as {base}/v1/projects/{project}/locations/{location}/publishers/google/models/{model}:generateContent, so it must know your GCP project and region. Litellm resolves them from per-call params (vertex_ai_project / vertex_ai_location), instance attributes, VERTEXAI_PROJECT / VERTEXAI_LOCATION env vars, module-level litellm.vertex_project / litellm.vertex_location, and secret stores. If both project and location are still unresolved, this ValueError is raised before any HTTP request. Supplying api_base bypasses the check entirely.","triggerScenarios":"litellm.image_edit(model='vertex_ai/gemini-2.5-flash-image', prompt=..., image=f) with no vertex_ai_project/vertex_ai_location kwargs, no VERTEXAI_PROJECT/VERTEXAI_LOCATION env vars, and no api_base. Common in fresh CI runners or containers where only GOOGLE_APPLICATION_CREDENTIALS is set (credentials are enough for the token, not for the URL).","commonSituations":"Auth succeeds via Application Default Credentials but project/location were never configured; setting GOOGLE_CLOUD_PROJECT instead of VERTEXAI_PROJECT (the former is not read here); passing the wrong kwarg name such as vertex_project instead of vertex_ai_project; env vars set in a shell but not in the server/proxy process.","solutions":["Pass vertex_ai_project='my-project' and vertex_ai_location='us-central1' directly on the litellm.image_edit() call","Or export VERTEXAI_PROJECT and VERTEXAI_LOCATION in the process environment","Or set module-level defaults: litellm.vertex_project='my-project'; litellm.vertex_location='us-central1'","For proxies/mocks, pass api_base='https://my-proxy/...' which skips project/location resolution and uses the URL as-is"],"exampleFix":"# before\nresp = litellm.image_edit(\n    model='vertex_ai/gemini-2.5-flash-image',\n    prompt='add a red hat',\n    image=open('cat.png', 'rb'),\n)  # raises: no project/location\n\n# after\nresp = litellm.image_edit(\n    model='vertex_ai/gemini-2.5-flash-image',\n    prompt='add a red hat',\n    image=open('cat.png', 'rb'),\n    vertex_ai_project='my-gcp-project',\n    vertex_ai_location='us-central1',\n)","handlingStrategy":"validation","validationCode":"import os\n\nVERTEX_PROJECT = os.environ.get('VERTEXAI_PROJECT')\nVERTEX_LOCATION = os.environ.get('VERTEXAI_LOCATION')\n\nif not VERTEX_PROJECT or not VERTEX_LOCATION:\n    raise RuntimeError('Set VERTEXAI_PROJECT and VERTEXAI_LOCATION (or pass vertex_ai_project/vertex_ai_location)')","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.image_edit(model='vertex_ai/gemini-2.5-flash-image', prompt=p, image=img)\nexcept ValueError as e:\n    if 'vertex_project and vertex_location are required' in str(e):\n        raise RuntimeError('Vertex AI config missing: set vertex_ai_project/vertex_ai_location') from e\n    raise","preventionTips":["Pass vertex_ai_project and vertex_ai_location explicitly on every vertex_ai call instead of relying on env","Assert required env vars at process startup, not at request time","Remember api_base bypasses project/location resolution — useful for mocks and proxies"],"tags":["vertex-ai","gemini","image-edit","configuration","gcp-project","missing-config"],"backgroundTag":"missing-required-config","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}