microsoft/semantic-kernel · error · NotSupportedException

Unsupported Cohere model: {modelId}

Error message

Unsupported Cohere model: {modelId}

What it means

CreateTextGenerationService routes Cohere models to either CohereCommandRService (name starts 'command-r') or CohereCommandService (name starts 'command-'). Any other Cohere model name throws NotSupportedException.

Source

Thrown at dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/BedrockServiceFactory.cs:80

                    return new AmazonService();
                }
                throw new NotSupportedException($"Unsupported Amazon model: {modelId}");
            case "ANTHROPIC":
                if (modelName.StartsWith("claude-", StringComparison.OrdinalIgnoreCase))
                {
                    return new AnthropicService();
                }
                throw new NotSupportedException($"Unsupported Anthropic model: {modelId}");
            case "COHERE":
                if (modelName.StartsWith("command-r", StringComparison.OrdinalIgnoreCase))
                {
                    return new CohereCommandRService();
                }
                if (modelName.StartsWith("command-", StringComparison.OrdinalIgnoreCase))
                {
                    return new CohereCommandService();
                }
                throw new NotSupportedException($"Unsupported Cohere model: {modelId}");
            case "META":
                if (modelName.StartsWith("llama3-", StringComparison.OrdinalIgnoreCase))
                {
                    return new MetaService();
                }
                throw new NotSupportedException($"Unsupported Meta model: {modelId}");
            case "MISTRAL":
                if (modelName.StartsWith("mistral-", StringComparison.OrdinalIgnoreCase)
                    || modelName.StartsWith("mixtral-", StringComparison.OrdinalIgnoreCase))
                {
                    return new MistralService();
                }
                throw new NotSupportedException($"Unsupported Mistral model: {modelId}");
            default:
                throw new NotSupportedException($"Unsupported model provider: {modelProvider}");
        }
    }

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Use a Cohere Command modelId for text generation, e.g. 'cohere.command-r-v1:0' or 'cohere.command-light-v1'.
  2. Ensure you are using the text-generation service, not the embedding service, for Command models.
  3. Upgrade Connectors.Amazon for newer Cohere support.

Example fix

// before - embedding id used for text generation
var modelId = "cohere.embed-english-v3:0";

// after
var modelId = "cohere.command-r-v1:0";
Defensive patterns

Strategy: validation

Validate before calling

static bool IsSupportedCohereTextModel(string modelId)
{
    var (provider, name) = SplitModelId(modelId);
    return provider.Equals("cohere", StringComparison.OrdinalIgnoreCase)
        && (name.StartsWith("command-r", StringComparison.OrdinalIgnoreCase)
            || name.StartsWith("command-", StringComparison.OrdinalIgnoreCase));
}

Type guard

static bool IsSupportedCohereTextModel(string modelId)
{
    var (provider, name) = SplitModelId(modelId);
    return provider.Equals("cohere", StringComparison.OrdinalIgnoreCase)
        && (name.StartsWith("command-r", StringComparison.OrdinalIgnoreCase)
            || name.StartsWith("command-", StringComparison.OrdinalIgnoreCase));
}

Try / catch

try
{
    var text = await bedrockTextGen.GetTextContentAsync(prompt, settings, ct);
}
catch (NotSupportedException ex) when (ex.Message.Contains("Cohere"))
{
    logger.LogError(ex, "Cohere modelId '{Id}' not supported for text generation. Use command-*.", modelId);
    throw;
}

Prevention

When it happens

Trigger: Text generation with modelId provider 'cohere' whose model-name segment starts with neither 'command-r' nor 'command-' (e.g. 'cohere.embed-multilingual-v3' used for text generation, or 'cohere.some-other-model').

Common situations: Using a Cohere embedding model id for a text-generation call. Wrong modelId. A Cohere model family not yet supported by this connector version.

Related errors


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