{"record":{"id":"d4d804df833ae559","repo":"BerriAI/litellm","slug":"vertex-project-and-vertex-location-are-required-fo-d4d804","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_imagen_transformation.py","lineNumber":132,"sourceCode":"            project_id=vertex_project,\n            custom_llm_provider=\"vertex_ai\",\n        )\n        return self.set_headers(access_token, headers)\n\n    def get_complete_url(\n        self,\n        model: str,\n        api_base: str | None,\n        litellm_params: dict,\n    ) -> str:\n        \"\"\"\n        Get the complete URL for Vertex AI Imagen predict API\n        \"\"\"\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        # 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 api_base:\n            base_url = api_base.rstrip(\"/\")\n        else:\n            base_url = get_vertex_base_url(vertex_location)\n\n        return f\"{base_url}/v1/projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/{model_name}:predict\"\n\n    def transform_image_edit_request(\n        self,\n        model: str,\n        prompt: str | None,\n        image: FileTypes | None,","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/image_edit/vertex_imagen_transformation.py#L114-L150","documentation":"Vertex AI Imagen image edit calls the predict API, whose URL embeds both the GCP project and the region: {base}/v1/projects/{project}/locations/{location}/publishers/google/models/{model}:predict. The config resolves them from vertex_ai_project/vertex_ai_location params, VERTEXAI_PROJECT/VERTEXAI_LOCATION (or VERTEX_LOCATION) env vars, module-level litellm.vertex_project/vertex_location, and secrets; if either is missing this ValueError fires. Important nuance: unlike the Gemini handlers, api_base does NOT bypass this check — project/location are needed to build the path even when api_base is supplied.","triggerScenarios":"litellm.image_edit(model='vertex_ai/imagen-3.0-capability-001', prompt=..., image=f, api_base='https://my-proxy') still raises, because the project/location check precedes the api_base branch; likewise any call without params or env vars set.","commonSituations":"Assuming a proxy api_base removes the need for project/location (it does not for Imagen edit); credentials-only setup (GOOGLE_APPLICATION_CREDENTIALS) with no project/location; env vars missing in dockerized proxy deployments.","solutions":["Pass vertex_ai_project='my-project' and vertex_ai_location='us-central1' on every image_edit call targeting vertex_ai/imagen-* edit models","Or export VERTEXAI_PROJECT and VERTEXAI_LOCATION in the process environment","Or set litellm.vertex_project / litellm.vertex_location module-level defaults","Do not rely on api_base alone for Imagen edit — it cannot substitute for project/location"],"exampleFix":"# before (raises even with api_base)\nresp = litellm.image_edit(\n    model='vertex_ai/imagen-3.0-capability-001',\n    prompt='remove the background',\n    image=open('cat.png', 'rb').read(),\n    api_base='https://my-proxy.example.com',\n)\n\n# after\nresp = litellm.image_edit(\n    model='vertex_ai/imagen-3.0-capability-001',\n    prompt='remove the background',\n    image=open('cat.png', 'rb').read(),\n    vertex_ai_project='my-gcp-project',\n    vertex_ai_location='us-central1',\n    api_base='https://my-proxy.example.com',\n)","handlingStrategy":"validation","validationCode":"import os\n\nproject = os.environ.get('VERTEXAI_PROJECT')\nlocation = os.environ.get('VERTEXAI_LOCATION') or os.environ.get('VERTEX_LOCATION')\nif not (project and location):\n    raise RuntimeError('imagen edit needs project+location even when api_base is set')","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.image_edit(model='vertex_ai/imagen-3.0-capability-001', prompt=p, image=img)\nexcept ValueError as e:\n    if 'vertex_project and vertex_location are required' in str(e):\n        raise RuntimeError('configure vertex_ai_project/vertex_ai_location (api_base will not bypass this)') from e\n    raise","preventionTips":["Never assume api_base replaces project/location for Imagen edit — it does not","Centralize Vertex config in one provider object that injects project/location into every call","Smoke-test config at deploy time with a tiny image_edit call"],"tags":["vertex-ai","imagen","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"}