{"record":{"id":"4fa0247309c8ec56","repo":"microsoft/semantic-kernel","slug":"unsupported-ai21-model-modelid","errorCode":null,"errorMessage":"Unsupported AI21 model: {modelId}","messagePattern":"Unsupported AI21 model: (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/BedrockServiceFactory.cs","lineNumber":58,"sourceCode":"    /// <param name=\"modelId\">The model to be used for the service.</param>\n    /// <returns><see cref=\"IBedrockTextGenerationService\"/> instance</returns>\n    /// <exception cref=\"NotSupportedException\">Thrown if provider or model is not supported for text generation.</exception>\n    internal IBedrockTextGenerationService CreateTextGenerationService(string modelId)\n    {\n        (string modelProvider, string modelName) = this.GetModelProviderAndName(ScrubCrossRegionPrefix(modelId));\n\n        switch (modelProvider.ToUpperInvariant())\n        {\n            case \"AI21\":\n                if (modelName.StartsWith(\"jamba\", StringComparison.OrdinalIgnoreCase))\n                {\n                    return new AI21JambaService();\n                }\n                if (modelName.StartsWith(\"j2-\", StringComparison.OrdinalIgnoreCase))\n                {\n                    return new AI21JurassicService();\n                }\n                throw new NotSupportedException($\"Unsupported AI21 model: {modelId}\");\n            case \"AMAZON\":\n                if (modelName.StartsWith(\"titan-\", StringComparison.OrdinalIgnoreCase))\n                {\n                    return new AmazonService();\n                }\n                throw new NotSupportedException($\"Unsupported Amazon model: {modelId}\");\n            case \"ANTHROPIC\":\n                if (modelName.StartsWith(\"claude-\", StringComparison.OrdinalIgnoreCase))\n                {\n                    return new AnthropicService();\n                }\n                throw new NotSupportedException($\"Unsupported Anthropic model: {modelId}\");\n            case \"COHERE\":\n                if (modelName.StartsWith(\"command-r\", StringComparison.OrdinalIgnoreCase))\n                {\n                    return new CohereCommandRService();\n                }\n                if (modelName.StartsWith(\"command-\", StringComparison.OrdinalIgnoreCase))","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/BedrockServiceFactory.cs#L40-L76","documentation":"CreateTextGenerationService routes an AI21 model to a text-generation service. AI21 is supported only for model names starting with 'jamba' (AI21JambaService) or 'j2-' (AI21JurassicService). Any other AI21 model name throws NotSupportedException. The model name is the segment after the first dot in the modelId.","triggerScenarios":"Calling text generation with modelId whose provider is 'ai21' but whose model-name segment matches neither 'jamba*' nor 'j2-*' (e.g. 'ai21.some-other-model'). Also a typo or a regional prefix that shifts parsing.","commonSituations":"Using a newly released AI21 model not yet recognized by the installed connector. Wrong/malformed modelId (missing dot, extra segment). Copying a modelId from docs that the current package version doesn't support.","solutions":["Use a supported AI21 text-generation modelId such as 'ai21.jamba-1-5-large-v1:0' or 'ai21.j2-ultra-v1'.","Upgrade Connectors.Amazon to add support for newer AI21 models.","Verify the modelId format is 'ai21.<model-name>' and that model access is enabled in the AWS Bedrock console."],"exampleFix":"// before\nvar modelId = \"ai21.jamba-instruct-v1\"; // name does not start with 'jamba' as expected? check exact prefix\n\n// after - use a recognized AI21 text-generation model\nvar modelId = \"ai21.jamba-1-5-large-v1:0\";","handlingStrategy":"validation","validationCode":"static bool IsSupportedAi21TextModel(string modelId)\n{\n    var (_, name) = SplitModelId(modelId);\n    return name.StartsWith(\"jamba\", StringComparison.OrdinalIgnoreCase)\n        || name.StartsWith(\"j2-\", StringComparison.OrdinalIgnoreCase);\n}\n\nstatic (string provider, string name) SplitModelId(string modelId)\n{\n    var parts = modelId.Split('.');\n    return (parts[0], parts.Length > 1 ? parts[1] : string.Empty);\n}","typeGuard":"static bool IsSupportedAi21TextModel(string modelId)\n{\n    var (_, name) = SplitModelId(modelId);\n    return name.StartsWith(\"jamba\", StringComparison.OrdinalIgnoreCase)\n        || name.StartsWith(\"j2-\", StringComparison.OrdinalIgnoreCase);\n}","tryCatchPattern":"try\n{\n    var text = await bedrockTextGen.GetTextContentAsync(prompt, settings, ct);\n}\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"AI21\"))\n{\n    logger.LogError(ex, \"AI21 modelId '{Id}' not supported for text generation. Use jamba* or j2-*.\", modelId);\n    throw;\n}","preventionTips":["Maintain a whitelist of supported modelIds per modality (text-gen, chat, embeddings).","Confirm model access is enabled in the AWS Bedrock console before using a modelId.","Keep the connector package updated to pick up newly added models."],"tags":["csharp","dotnet","semantic-kernel","bedrock","aws","ai21","model-id","not-supported"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}