microsoft/semantic-kernel · error · ValueError

Unsupported service name: {service_name}

Error message

Unsupported service name: {service_name}

What it means

A ValueError from the text-embedding setup dispatcher when service_name is not among its supported keys. The embedding dispatcher supports a different set than text completion: AZURE_OPENAI, AZURE_AI_INFERENCE, BEDROCK, GOOGLE_AI, HUGGING_FACE, MISTRAL_AI, OLLAMA, VERTEX_AI. Notably it omits OPENAI (base) and ONNX but adds the Azure variants and Mistral.

Source

Thrown at python/samples/concepts/setup/text_embedding_services.py:53

    Returns:
        Tuple[EmbeddingGeneratorBase, PromptExecutionSettings]: The embedding service and request settings.
    """
    # Use lambdas to delay instantiation of the services until needed.
    embedding_services = {
        Services.OPENAI: lambda: get_openai_text_embedding_service_and_request_settings(),
        Services.AZURE_OPENAI: lambda: get_azure_openai_text_embedding_service_and_request_settings(),
        Services.AZURE_AI_INFERENCE: lambda: get_azure_ai_inference_text_embedding_service_and_request_settings(),
        Services.BEDROCK: lambda: get_bedrock_text_embedding_service_and_request_settings(),
        Services.GOOGLE_AI: lambda: get_google_ai_text_embedding_service_and_request_settings(),
        Services.HUGGING_FACE: lambda: get_hugging_face_text_embedding_service_and_request_settings(),
        Services.MISTRAL_AI: lambda: get_mistral_ai_text_embedding_service_and_request_settings(),
        Services.OLLAMA: lambda: get_ollama_text_embedding_service_and_request_settings(),
        Services.VERTEX_AI: lambda: get_vertex_ai_text_embedding_service_and_request_settings(),
    }

    # Call the appropriate lambda or function based on the service name
    if service_name not in embedding_services:
        raise ValueError(f"Unsupported service name: {service_name}")
    return embedding_services[service_name]()


def get_openai_text_embedding_service_and_request_settings() -> tuple[
    "EmbeddingGeneratorBase", "PromptExecutionSettings"
]:
    """Return OpenAI embedding service and request settings.

    The service credentials can be read by 3 ways:
    1. Via the constructor
    2. Via the environment variables
    3. Via an environment file

    The request settings control the behavior of the service. The default settings are sufficient to get started.
    However, you can adjust the settings to suit your needs.
    Note: Some of the settings are NOT meant to be set by the user.
    Please refer to the Semantic Kernel Python documentation for more information:
    https://learn.microsoft.com/en-us/python/api/semantic-kernel/semantic_kernel?view=semantic-kernel-python

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Pass a supported Services member for embeddings: AZURE_OPENAI, AZURE_AI_INFERENCE, BEDROCK, GOOGLE_AI, HUGGING_FACE, MISTRAL_AI, OLLAMA, or VERTEX_AI.
  2. If you need base OpenAI embeddings, add a get_openai_text_embedding_service_and_request_settings lambda to the dict.
  3. Cross-check the requested enum member against the dict keys shown in the error's source region.

Example fix

// before
embedding_services(Services.OPENAI)

// after
embedding_services(Services.AZURE_OPENAI)
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_EMBED = {Services.AZURE_OPENAI, Services.AZURE_AI_INFERENCE, Services.BEDROCK, Services.GOOGLE_AI, Services.HUGGING_FACE, Services.MISTRAL_AI, Services.OLLAMA, Services.VERTEX_AI}
assert service_name in SUPPORTED_EMBED, f"{service_name} not supported for embeddings"

Type guard

def is_supported_embedding_service(name) -> bool:
    return name in {Services.AZURE_OPENAI, Services.AZURE_AI_INFERENCE, Services.BEDROCK, Services.GOOGLE_AI, Services.HUGGING_FACE, Services.MISTRAL_AI, Services.OLLAMA, Services.VERTEX_AI}

Try / catch

try:
    svc, settings = text_embedding_services(service_name)
except ValueError:
    # notify that the embedding dispatcher supports a different set than text completion
    ...

Prevention

When it happens

Trigger: Calling the embedding dispatcher with Services.OPENAI or Services.ONNX (not wired here), or any value outside the supported set.

Common situations: Assuming the embedding dispatcher supports the same services as the text-completion one; passing Services.OPENAI expecting base OpenAI embeddings when only AZURE_OPENAI is wired; typo in the enum value.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/4c97e25da7d76cd0. Report an issue: GitHub.