{"record":{"id":"b43c0e8a38f51601","repo":"BerriAI/litellm","slug":"model-parameter-is-required-for-gemini-custom-api","errorCode":null,"errorMessage":"Model parameter is required for Gemini custom API base URLs","messagePattern":"Model parameter is required for Gemini custom API base URLs","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/vertex_llm_base.py","lineNumber":639,"sourceCode":"        1. Gemini (Google AI Studio) - constructs /models/{model}:{endpoint}\n        2. Vertex AI with standard proxies - constructs {api_base}:{endpoint};\n           if api_base has no path (bare host), grafts the default vertex URL path onto it\n        3. Vertex AI with PSC endpoints - constructs full path structure\n           {api_base}/v1/projects/{project}/locations/{location}/endpoints/{model}:{endpoint}\n           (only when use_psc_endpoint_format=True)\n\n        Args:\n            use_psc_endpoint_format: If True, constructs PSC endpoint URL format.\n                                     If False (default), uses api_base as-is and appends :{endpoint}\n\n        ## Returns\n        - (auth_header, url) - Tuple[Optional[str], str]\n        \"\"\"\n        if api_base:\n            if custom_llm_provider == \"gemini\":\n                # For Gemini (Google AI Studio), construct the full path like other providers\n                if model is None:\n                    raise ValueError(\"Model parameter is required for Gemini custom API base URLs\")\n                url = f\"{api_base}/models/{model}:{endpoint}\"\n                if gemini_api_key is None:\n                    raise ValueError(\n                        \"Missing Gemini API key. Set the GEMINI_API_KEY or GOOGLE_API_KEY environment variable.\"\n                    )\n                if gemini_api_key is not None:\n                    auth_header = {\"x-goog-api-key\": gemini_api_key}\n            else:\n                # For Vertex AI\n                if use_psc_endpoint_format:\n                    # User explicitly specified PSC endpoint format\n                    # Construct full PSC/custom endpoint URL\n                    if not (vertex_project and vertex_location and model):\n                        raise ValueError(\n                            \"vertex_project, vertex_location, and model are required when use_psc_endpoint_format=True\"\n                        )\n                    # Strip routing prefixes (bge/, gemma/, etc.) for endpoint URL construction\n                    model_for_url: Final = get_vertex_base_model_name(model=model)","sourceCodeStart":621,"sourceCodeEnd":657,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/vertex_llm_base.py#L621-L657","documentation":"Raised in URL construction for a Gemini (Google AI Studio) custom api_base: no model name was supplied, so the /models/{model}:{endpoint} path cannot be built. Gemini custom bases have no default model to fall back to.","triggerScenarios":"Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:639 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the 'model' parameter when using a custom api_base for Gemini so the request path can be constructed.","Include the model name in the call, e.g. model='vertex_ai/gemini-1.5-pro' together with api_base."],"exampleFix":null,"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"}