{"id":143,"library":"vertexai","title":"Vertex AI SDK (Python)","description":"Google Cloud Vertex AI SDK for Python. Two separate PyPI packages exist: google-cloud-aiplatform (GAPIC clients, full Vertex AI platform) and vertexai (higher-level SDK, same underlying package). Install is google-cloud-aiplatform, import is vertexai — classic name mismatch. Generative AI modules (vertexai.generative_models, vertexai.language_models, etc.) deprecated June 24, 2025 and will be removed June 24, 2026. Current version: google-cloud-aiplatform 1.142.0 / vertexai 1.71.1.","status":"active","version":"1.142.0","language":"python","source_language":"en","source_url":"https://github.com/googleapis/python-aiplatform","tags":["google","vertex-ai","gemini","gcp","python","cloud","llm"],"install":[{"cmd":"pip install google-cloud-aiplatform","lang":"bash","label":"Python (installs both google-cloud-aiplatform and vertexai)"},{"cmd":"pip install vertexai","lang":"bash","label":"Python (alternative — same package, different PyPI name)"},{"cmd":"pip install 'google-cloud-aiplatform[agent_engines,adk]'","lang":"bash","label":"Python (with Agent Engine and ADK support)"}],"dependencies":[{"reason":"Required for Application Default Credentials. Installed automatically.","package":"google-auth","optional":false},{"reason":"Required for new generative AI features. Generative AI modules moving from vertexai to google-genai.","package":"google-genai","optional":true}],"imports":[{"note":"install is google-cloud-aiplatform but import is vertexai — not google.cloud.aiplatform. Both packages coexist but vertexai is the high-level SDK. google.cloud.aiplatform is the low-level GAPIC client.","wrong":"from google.cloud import aiplatform\naiplatform.init(project='your-project-id', location='us-central1')","symbol":"vertexai.init","correct":"import vertexai\n\nvertexai.init(\n    project='your-project-id',\n    location='us-central1'\n)"},{"note":"vertexai.generative_models deprecated June 24, 2025. Removed June 24, 2026. Migrate to google-genai with vertexai=True.","wrong":"import vertexai\nfrom vertexai.generative_models import GenerativeModel\n\nvertexai.init(project='your-project', location='us-central1')\nmodel = GenerativeModel('gemini-2.5-flash')\nresponse = model.generate_content('Explain neural networks')\nprint(response.text)","symbol":"vertexai.generative_models (deprecated)","correct":"# Use google-genai for generative AI on Vertex AI\nfrom google import genai\n\nclient = genai.Client(\n    vertexai=True,\n    project='your-project-id',\n    location='us-central1'\n)\nresponse = client.models.generate_content(\n    model='gemini-2.5-flash',\n    contents='Explain neural networks'\n)\nprint(response.text)"},{"note":"Vertex AI does not use API keys. Uses Google Cloud Application Default Credentials (ADC) or service account JSON. No api_key parameter exists on vertexai.init().","wrong":"import vertexai\nvertexai.init(project='your-project-id', location='us-central1', credentials='your-api-key')","symbol":"Application Default Credentials","correct":"import vertexai\n\n# Uses ADC automatically — run: gcloud auth application-default login\nvertexai.init(project='your-project-id', location='us-central1')"}],"quickstart":{"code":"# For Vertex AI generative AI — use google-genai\n# pip install google-genai\nfrom google import genai\n\nclient = genai.Client(\n    vertexai=True,\n    project='your-gcp-project-id',\n    location='us-central1'\n)\n\nresponse = client.models.generate_content(\n    model='gemini-2.5-flash',\n    contents='What is Vertex AI?'\n)\nprint(response.text)","lang":"python","description":"Vertex AI Gemini call using google-genai with vertexai=True (recommended path from 2025 onwards)."},"warnings":[{"fix":"pip install google-cloud-aiplatform; import vertexai","message":"Install package is google-cloud-aiplatform but import is 'import vertexai'. LLMs consistently confuse this and generate 'from google.cloud import vertexai' or 'pip install vertexai-sdk'. Both are wrong.","severity":"breaking","affected_versions":"all"},{"fix":"Migrate to google-genai with vertexai=True. See migration guide at cloud.google.com/vertex-ai/generative-ai/docs/deprecations/genai-vertexai-sdk","message":"vertexai.generative_models, vertexai.language_models, vertexai.vision_models, vertexai.tuning, vertexai.caching deprecated June 24, 2025. Will be removed June 24, 2026.","severity":"breaking","affected_versions":">= 1.114.0"},{"fix":"Run: gcloud auth application-default login. Or set GOOGLE_APPLICATION_CREDENTIALS to service account JSON path.","message":"Vertex AI does not use API keys. Uses Application Default Credentials (ADC). No api_key parameter. LLMs frequently hallucinate an api_key argument on vertexai.init().","severity":"breaking","affected_versions":"all"},{"fix":"Pin only one. Prefer google-cloud-aiplatform for consistency with GCP tooling.","message":"Two PyPI packages: google-cloud-aiplatform and vertexai. They install the same underlying package. Installing either gives you both namespaces. Pinning both to different versions causes conflicts.","severity":"gotcha","affected_versions":"all"},{"fix":"Always call vertexai.init(project='...', location='...') at startup.","message":"vertexai.init() must be called before any Vertex AI SDK calls. Forgetting this causes authentication or project resolution errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Always pass location='us-central1' or your preferred region.","message":"location parameter is required and must be a valid GCP region. 'us-central1' is most common. Wrong or missing location raises InvalidArgument errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.142.0':73 '1.71.1':75 '2025':59 '2026':66 '24':58,65 'ai':2,8,25,49,79 'aiplatform':20,41,72 'classic':45 'client':22 'cloud':6,19,40,71,83 'current':67 'deprec':56 'etc':55 'exist':16 'full':23 'gapic':21 'gcp':81 'gemini':80 'generat':48 'googl':5,18,39,70,76 'google-cloud-aiplatform':17,38,69 'higher':30 'higher-level':29 'import':42 'instal':36 'june':57,64 'level':31 'llm':84 'mismatch':47 'model':52,54 'modul':50 'name':46 'packag':15,35 'platform':26 'pypi':14 'python':4,11,82 'remov':63 'sdk':3,9,32 'separ':13 'two':12 'under':34 'version':68 'vertex':1,7,24,78 'vertex-ai':77 'vertexai':28,44,74 'vertexai.generative':51 'vertexai.language':53","created_at":"2026-03-24T04:00:55.608125+00:00","updated_at":"2026-04-17T00:15:13.522647+00:00","problems":[{"fix":"pip install google-cloud-aiplatform","cause":"The `vertexai` SDK is part of the `google-cloud-aiplatform` package, which was not installed or installed incorrectly.","error":"ModuleNotFoundError: No module named 'vertexai'"},{"fix":"Verify the model ID and ensure the `location` parameter in `vertexai.init()` or `GenerativeModel()` call matches a region where the model is available.","cause":"The specified model name (e.g., `gemini-pro`) is either misspelled or not available in the Google Cloud region specified during `vertexai.init()` or model instantiation.","error":"google.api_core.exceptions.InvalidArgument: 400 The model specified does not exist in this region."},{"fix":"Authenticate using `gcloud auth application-default login`, set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable, or ensure a service account with the 'Vertex AI User' role is active.","cause":"The environment lacks valid Google Cloud credentials, or the service account/user running the code does not have the necessary permissions to access Vertex AI resources.","error":"google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials."},{"fix":"Call `vertexai.init(project=\"your-project-id\", location=\"your-region\")` or set the `GCLOUD_PROJECT` environment variable.","cause":"The `vertexai.init()` function could not automatically determine the Google Cloud project ID from environment variables, and it was not explicitly provided.","error":"ValueError: Project ID must be specified"},{"fix":"Ensure `vertexai.init()` is called with correct project/location, the `GenerativeModel` is instantiated with a valid model name, and verify that the model object is not `None` before attempting to call generation methods.","cause":"The `GenerativeModel` or `ChatSession` object was not successfully initialized, often due to an issue during its creation (e.g., invalid model name, region, or authentication failure), resulting in the variable being `None`.","error":"AttributeError: 'NoneType' object has no attribute 'generate_content'"}],"ecosystem":"pypi","meta_description":null,"install_score":80,"quickstart_score":60,"quickstart_tag":"reviewed","pypi_latest":"1.71.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://cloud.google.com/vertex-ai","github":"https://github.com/googleapis/python-aiplatform","docs":null,"changelog":null,"pypi":"https://pypi.org/project/vertexai/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["gcp","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-27","last_verified":"2026-08-26","next_check":"2026-07-27","install_tag":"verified"}}