Skip to content

OpenRouter compatible with SemanticKernel #14

@sebastianrosch

Description

@sebastianrosch

Hi, we're using SemanticKernel in C# with plugins and function calling and would like to switch to OpenRouter. I am getting an exception from the OpenAI SDK which SemanticKernel uses internally when parsing the response from OpenRouter.

System.NullReferenceException: Object reference not set to an instance of an object.
   at OpenAI.Chat.ChatCompletion.get_Refusal()
   at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.GetChatCompletionMetadata(ChatCompletion completions)
   at Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.CreateChatMessageContent(ChatCompletion completion, String targetModel)

I assume it comes from this line: https://github.com/openai/openai-dotnet/blob/c046c34ad06f7ca050b2f8044cfc8372d8cf0e76/src/Custom/Chat/ChatCompletion.cs#L82

Is there any special configuration required to make this work with SemanticKernel?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions