BerriAI/litellm · critical · NotFoundError

AzureException NotFoundError - {message}

Error message

AzureException NotFoundError - {message}

What it means

litellm maps Azure OpenAI 'DeploymentNotFound' errors to litellm.NotFoundError. Azure could not resolve the deployment name in the URL - the named deployment does not exist under that resource and API version.

Source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1913

    if "Internal server error" in error_str:
        raise litellm.InternalServerError(
            message=f"AzureException Internal server error - {message}",
            llm_provider="azure",
            model=model,
            litellm_debug_info=extra_information,
            response=getattr(original_exception, "response", None),
        )
    elif "This model's maximum context length is" in error_str:
        raise ContextWindowExceededError(
            message=f"AzureException ContextWindowExceededError - {message}",
            llm_provider="azure",
            model=model,
            litellm_debug_info=extra_information,
            response=getattr(original_exception, "response", None),
        )
    elif "DeploymentNotFound" in error_str:
        raise NotFoundError(
            message=f"AzureException NotFoundError - {message}",
            llm_provider="azure",
            model=model,
            litellm_debug_info=extra_information,
            response=getattr(original_exception, "response", None),
        )
    elif azure_error_code == "content_policy_violation" or ExceptionCheckers.is_azure_content_policy_violation_error(
        error_str
    ):
        from litellm.llms.azure.exception_mapping import (
            AzureOpenAIExceptionMapping,
        )

        raise AzureOpenAIExceptionMapping.create_content_policy_violation_error(
            message=message,
            model=model,
            extra_information=extra_information,
            original_exception=original_exception,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Check the deployment name in Azure portal (Azure OpenAI > Deployments) and make it match the litellm model string exactly (case-sensitive)
  2. Verify api_base points at the right resource and api_version is current
  3. If the deployment was renamed, update config/env (AZURE_API_BASE, AZURE_DEPLOYMENT_NAME or model_list entries)
  4. Use azure/deployment or explicit azure_deployment= param rather than embedding names in code
  5. Redeploy the model if it was deleted

Example fix

# before
litellm.completion(model='azure/gpt4o-prod', messages=msgs)  # actual name: gpt-4o-prod
# after
litellm.completion(model='azure/gpt-4o-prod', messages=msgs,
                   api_base=os.environ['AZURE_API_BASE'], api_key=os.environ['AZURE_API_KEY'],
                   api_version='2024-10-21')
Defensive patterns

Strategy: validation

Validate before calling

from azure.identity import DefaultAzureCredential
from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient
sub, rg, res = '<sub>', '<rg>', '<resource>'
client = CognitiveServicesManagementClient(DefaultAzureCredential(), sub)
names = {d.name for d in client.deployments.list(rg, res)}
assert 'gpt-4o-prod' in names, f'deployment missing; have {names}'

Type guard

import litellm

def is_azure_deployment_missing(e: Exception) -> bool:
    return isinstance(e, litellm.NotFoundError) and 'DeploymentNotFound' in str(e)

Try / catch

try:
    litellm.completion(model='azure/gpt-4o-prod', messages=msgs)
except litellm.NotFoundError as e:
    if 'DeploymentNotFound' in str(e):
        raise RuntimeError('deployment name mismatch - check Azure portal')
    raise

Prevention

When it happens

Trigger: Calling model='azure/<deployment>' where <deployment> does not match an actual deployment name in the Azure OpenAI resource: typos, deployment deleted/renamed, wrong resource (multiple accounts), or an api_version that no longer resolves the deployment.

Common situations: Env-specific config drift (dev deployment name used in prod), deployments recreated after region moves with new names, api_version deprecations, or base_url pointing at the wrong resource.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/e49c7f1585440315. Report an issue: GitHub.