BerriAI/litellm · error · ValueError

Invalid credentials type: {type(credentials)}

Error message

Invalid credentials type: {type(credentials)}

What it means

Type guard on the credentials parameter in load_auth: it is neither None, a str, nor a dict (the supported VERTEX_CREDENTIALS_TYPES), so LiteLLM does not know how to interpret it. The unexpected type is reported.

Source

Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:128

                    os.getcwd(),
                )

                try:
                    if _is_path:
                        with open(credentials) as f:
                            json_obj = json.load(f)
                    else:
                        json_obj = json.loads(credentials)
                except Exception as e:
                    raise Exception(
                        "Unable to load vertex credentials from environment. "
                        "Ensure the JSON is valid (check for unescaped newlines in private_key). "
                        f"Parse error: {type(e).__name__}"
                    )
            elif isinstance(credentials, dict):
                json_obj = credentials
            else:
                raise ValueError(f"Invalid credentials type: {type(credentials)}")

            # Check if the JSON object contains Workload Identity Federation configuration
            if "type" in json_obj and json_obj["type"] == "external_account":
                # If environment_id key contains "aws" value it corresponds to an AWS config file
                credential_source: Final = json_obj.get("credential_source", {})
                environment_id: Final = (
                    credential_source.get("environment_id", "") if isinstance(credential_source, dict) else ""
                )
                if isinstance(environment_id, str) and "aws" in environment_id:
                    # Check if explicit AWS params are in the JSON (bypasses metadata)
                    from litellm.llms.vertex_ai.vertex_ai_aws_wif import (
                        VertexAIAwsWifAuth,
                    )

                    aws_params: Final = VertexAIAwsWifAuth.extract_aws_params(json_obj)
                    if aws_params:
                        creds = VertexAIAwsWifAuth.credentials_from_explicit_aws(
                            json_obj,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass credentials as a google.oauth2 Credentials object, a dict of the service account JSON, or a path to the JSON key file.
  2. Check the reported type in the error and convert it to one of the supported credential forms.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:128 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/061614b1dac2005b. Report an issue: GitHub.