openai / openai-dotnet

The official .NET library for the OpenAI API
https://www.nuget.org/packages/OpenAI
MIT License
707 stars 60 forks source link

Allow ApiKey to be optional in the OpenAIClient constructor. #90

Open RogerBarreto opened 5 days ago

RogerBarreto commented 5 days ago

This will allow the OpenAIClient be used against custom OpenAI Gateways that intercept and inject the apikey, in the pipeline without having to provide a fake key on the caller code.

This also allows the client to be used against other OpenAI compatible endpoints that don't require ApiKey to be sent in the header.

https://github.com/openai/openai-dotnet/blob/0b97311f58dfb28bd883d990f68d548da040a807/src/Custom/OpenAIClient.cs#L58

Consider not having an empty check or allow us to use a NullCredential.Instance in the System.ClientModel package.

https://github.com/Azure/azure-sdk-for-net/blob/d1cac0ba5673ddcb999846d560c13f71f7b259fe/sdk/core/System.ClientModel/src/Convenience/ApiKeyCredential.cs#L64 image