{"record":{"id":"a44956dc34b2ce1d","repo":"microsoft/semantic-kernel","slug":"unsupported-service-name-service-name-a44956","errorCode":null,"errorMessage":"Unsupported service name: {service_name}","messagePattern":"Unsupported service name: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/samples/concepts/setup/text_completion_services.py","lineNumber":48,"sourceCode":"    \"\"\"Return service and request settings.\n\n    Args:\n        service_name (Services): The service name.\n    \"\"\"\n    # Use lambdas or functions to delay instantiation\n    text_services = {\n        Services.OPENAI: lambda: get_openai_text_completion_service_and_request_settings(),\n        Services.BEDROCK: lambda: get_bedrock_text_completion_service_and_request_settings(),\n        Services.GOOGLE_AI: lambda: get_google_ai_text_completion_service_and_request_settings(),\n        Services.HUGGING_FACE: lambda: get_hugging_face_text_completion_service_and_request_settings(),\n        Services.OLLAMA: lambda: get_ollama_text_completion_service_and_request_settings(),\n        Services.ONNX: lambda: get_onnx_text_completion_service_and_request_settings(),\n        Services.VERTEX_AI: lambda: get_vertex_ai_text_completion_service_and_request_settings(),\n    }\n\n    # Call the appropriate lambda or function based on the service name\n    if service_name not in text_services:\n        raise ValueError(f\"Unsupported service name: {service_name}\")\n    return text_services[service_name]()\n\n\ndef get_openai_text_completion_service_and_request_settings() -> tuple[\n    \"TextCompletionClientBase\", \"PromptExecutionSettings\"\n]:\n    \"\"\"Return OpenAI text completion service and request settings.\n\n    The service credentials can be read by 3 ways:\n    1. Via the constructor\n    2. Via the environment variables\n    3. Via an environment file\n\n    The request settings control the behavior of the service. The default settings are sufficient to get started.\n    However, you can adjust the settings to suit your needs.\n    Note: Some of the settings are NOT meant to be set by the user.\n    Please refer to the Semantic Kernel Python documentation for more information:\n    https://learn.microsoft.com/en-us/python/api/semantic-kernel/semantic_kernel?view=semantic-kernel-python","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/samples/concepts/setup/text_completion_services.py#L30-L66","documentation":"A ValueError raised by the text-completion setup dispatcher when the requested service_name does not match any key in its supported services dict. The dispatcher only knows a fixed set (OPENAI, BEDROCK, GOOGLE_AI, HUGGING_FACE, OLLAMA, ONNX, VERTEX_AI); anything else is rejected rather than silently ignored.","triggerScenarios":"Calling the dispatcher with a Services enum member (or string) not present in the text_services dict keys, e.g. passing Services.AZURE_OPENAI which has no text-completion lambda wired here.","commonSituations":"Passing a raw string that doesn't match the enum value; using a Services member that is valid for chat/embedding but not for text completion; a typo; expecting ONNX-style names that differ from the enum.","solutions":["Pass one of the supported Services members: OPENAI, BEDROCK, GOOGLE_AI, HUGGING_FACE, OLLAMA, ONNX, or VERTEX_AI.","If you need a service not in the list, add its lambda to the text_services dict in this sample file.","Check the exact value of service_name against Services enum definitions before calling."],"exampleFix":"// before\ntext_completion_services(Services.AZURE_OPENAI)\n\n// after\ntext_completion_services(Services.OPENAI)","handlingStrategy":"validation","validationCode":"from semantic_kernel.services import Services  # adjust import to actual enum location\n\nSUPPORTED_TEXT = {Services.OPENAI, Services.BEDROCK, Services.GOOGLE_AI, Services.HUGGING_FACE, Services.OLLAMA, Services.ONNX, Services.VERTEX_AI}\nassert service_name in SUPPORTED_TEXT, f\"{service_name} not supported for text completion\"","typeGuard":"def is_supported_text_service(name) -> bool:\n    return name in {Services.OPENAI, Services.BEDROCK, Services.GOOGLE_AI, Services.HUGGING_FACE, Services.OLLAMA, Services.ONNX, Services.VERTEX_AI}","tryCatchPattern":"try:\n    svc, settings = text_completion_services(service_name)\nexcept ValueError:\n    # fallback or prompt user for a supported service name\n    ...","preventionTips":["Derive the service name from the Services enum, never a hand-typed string.","Maintain a single source-of-truth list of supported services for each dispatcher."],"tags":["configuration","dispatch","validation","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}