Skip to content

gemini/ provider with custom api_base requires api_key even when azure_ad_token is set #26702

@madhu19991

Description

@madhu19991

Describe the bug

When creating a model with model: gemini/gemini-3-flash-preview and a custom api_base, LiteLLM throws Missing gemini_api_key, please set GEMINI_API_KEY even when azure_ad_token is set in litellm_params. However, an existing model on the same proxy with identical config works fine.

Context

We have two models on gsk-prod with identical litellm_params:

Field Value
model gemini/gemini-3-flash-preview
api_base https://dev.api.gsk.com/co/ent/gcp/gemini3-flash/global
drop_params true
azure_ad_token set (non-empty)
  • GSKPlatform_gemini-3.0-flash — created on an older version, works correctly
  • Kc3ajs8TEUyP7jsX27WQwg_gemini-3.0-flash — newly created with same params, fails with Missing gemini_api_key

The newly created model only works after adding api_key to litellm_params. The existing model has no api_key field and works without it.

Error

litellm.APIConnectionError: Missing gemini_api_key, please set `GEMINI_API_KEY`
  File ".../litellm/llms/vertex_ai/vertex_llm_base.py", line 360, in _check_custom_proxy
    raise ValueError("Missing gemini_api_key, please set `GEMINI_API_KEY`")

Stack: vertex_and_google_ai_studio_gemini.py:async_completionvertex_llm_base.py:_get_token_and_url_check_custom_proxy

Questions to investigate

  1. Why does azure_ad_token not satisfy auth resolution in _check_custom_proxy for gemini/ provider with a custom api_base?
  2. What is different about the older model that allows it to work without api_key? Is there a DB field not returned by /model/info that's being used?
  3. Should azure_ad_token be a valid auth mechanism for gemini/ provider with custom api_base, or is api_key the correct field?

Environment

  • LiteLLM version: v1.81.14
  • Provider: gemini/ with custom api_base (non-Google endpoint)
  • Proxy: multi-pod GKE deployment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions