{"id":13543251,"url":"https://github.com/betalgo/openai","last_synced_at":"2025-04-29T18:22:28.684Z","repository":{"id":36996399,"uuid":"432730711","full_name":"betalgo/openai","owner":"betalgo","description":".NET library for the OpenAI service API by Betalgo Ranul","archived":false,"fork":false,"pushed_at":"2025-04-23T23:54:49.000Z","size":4286,"stargazers_count":2958,"open_issues_count":16,"forks_count":539,"subscribers_count":67,"default_branch":"master","last_synced_at":"2025-04-24T00:29:48.402Z","etag":null,"topics":["azure-openai","chatgpt","csharp","dall-e","dotnet","gpt-3","gpt-4","openai","openai-api","ranul","sdk","tinga","whisper","whisper-ai"],"latest_commit_sha":null,"homepage":"https://ranultinga.com/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/betalgo.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["kayhantolga"]}},"created_at":"2021-11-28T14:11:38.000Z","updated_at":"2025-04-23T23:52:37.000Z","dependencies_parsed_at":"2024-01-30T10:26:09.441Z","dependency_job_id":"83cc592d-3917-4cf4-93fa-8cddf46632bc","html_url":"https://github.com/betalgo/openai","commit_stats":{"total_commits":435,"total_committers":50,"mean_commits":8.7,"dds":"0.32413793103448274","last_synced_commit":"7f153b32006910c443127c62a4ee416ede9e1c0d"},"previous_names":[],"tags_count":75,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betalgo%2Fopenai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betalgo%2Fopenai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betalgo%2Fopenai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betalgo%2Fopenai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/betalgo","download_url":"https://codeload.github.com/betalgo/openai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251556822,"owners_count":21608522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure-openai","chatgpt","csharp","dall-e","dotnet","gpt-3","gpt-4","openai","openai-api","ranul","sdk","tinga","whisper","whisper-ai"],"created_at":"2024-08-01T11:00:27.720Z","updated_at":"2025-04-29T18:22:28.668Z","avatar_url":"https://github.com/betalgo.png","language":"C#","funding_links":["https://github.com/sponsors/kayhantolga"],"categories":["精选开源项目合集","C#","Openai","C\\#","A01_文本生成_文本对话","dotnet","Open API","SDK, Libraries, Frameworks","chatgpt"],"sub_categories":["GTP编程语言客户端","大语言对话模型及数据","提示语（魔法）","C# library, sdk or frameworks"],"readme":"![Betalgo Ranul OpenAI Github readme banner](https://github.com/user-attachments/assets/3a76387f-e033-4ee2-a9c7-2ebf047c4d90)\n\n## Overview\nA .NET Library for accessing OpenAI's API, provided as a community library. This Library allows you to integrate OpenAI's capabilities into your .NET applications with ease.\n\n⭐ We appreciate your star, it helps! ![GitHub Repo stars](https://img.shields.io/github/stars/betalgo/openai)  \n #### Community Links\n- [![Discord](https://img.shields.io/discord/1250841506785529916?label=Discord)](https://discord.gg/gfgHsWnGxy) Please come and help us build the .NET AI community  \n- [![Static Badge](https://img.shields.io/badge/Reddit-Betalgo%20Developers-orange)](https://www.reddit.com/r/BetalgoDevelopers)\n- [![Static Badge](https://img.shields.io/badge/Github-Discussions-black)](https://github.com/betalgo/openai/discussions)\n \n### Install Packages\n#### Core Library\n⚠️ We now have new PackageId and new Namespace. ⚠️  \n⚠️ `Betalgo.OpenAI` is now `Betalgo.Ranul.OpenAI` ⚠️  \n\n[![Betalgo.Ranul.OpenAI](https://img.shields.io/nuget/v/Betalgo.Ranul.OpenAI?style=for-the-badge)](https://www.nuget.org/packages/Betalgo.Ranul.OpenAI/)\n```shell\nInstall-Package Betalgo.Ranul.OpenAI\n```\n\n#### Experimental Utilities Library\n[![Betalgo.OpenAI.Utilities](https://img.shields.io/nuget/v/Betalgo.OpenAI.Utilities?style=for-the-badge)](https://www.nuget.org/packages/Betalgo.OpenAI.Utilities/)\n```shell\nInstall-Package Betalgo.OpenAI.Utilities\n```\n\n## Documentation and Links\n- [Realtime API](https://github.com/betalgo/openai/wiki/realtime) ✨NEW\n- [Wiki Page](https://github.com/betalgo/openai/wiki)\n- [Feature Availability Table](https://github.com/betalgo/openai/wiki/Feature-Availability)\n- [Change Logs](https://github.com/betalgo/openai/wiki/Change-Logs)\n- [Migration Guide for Breaking Changes](https://github.com/betalgo/openai/wiki/Migration-Guides-for-breaking-changes)\n---\n\n## Acknowledgements\nMaintenance of this project is made possible by all the bug reporters, [contributors](https://github.com/betalgo/openai/graphs/contributors), and [sponsors](https://github.com/sponsors/kayhantolga).\n\n💖 Sponsors:  \n[@betalgo](https://github.com/betalgo), [Laser Cat Eyes](https://lasercateyes.com/)   \n[@tylerje](https://github.com/tylerje), [@oferavnery](https://github.com/oferavnery), [@MayDay-wpf](https://github.com/MayDay-wpf), [@AnukarOP](https://github.com/AnukarOP), [@Removable](https://github.com/Removable), [@Scar11](https://github.com/Scar11)\n\n---\n\n## Sample Usage\nThe repository contains a sample project named **OpenAI.Playground** to help you understand how the library works. However, please exercise caution while experimenting, as some test methods may result in unintended consequences such as file deletion or fine-tuning.\n\n*!! It is highly recommended that you use a separate account instead of your primary account while using the playground. Some test methods may add or delete your files and models, potentially causing unwanted issues. !!*\n\nYour API Key can be obtained from here: https://platform.openai.com/account/api-keys  \nYour Organization ID can be found here: https://platform.openai.com/account/org-settings\n\n### Without Using Dependency Injection\n```csharp\nvar openAIService = new OpenAIService(new OpenAIOptions()\n{\n    ApiKey = Environment.GetEnvironmentVariable(\"MY_OPEN_AI_API_KEY\")\n});\n```\n\n### Using Dependency Injection\n\n#### secrets.json\n```json\n\"OpenAIServiceOptions\": {\n    \"ApiKey\": \"Your api key goes here\",\n    \"Organization\": \"Your Organization Id goes here (optional)\",\n    \"UseBeta\": \"true/false (optional)\"\n}\n```\n*(To use [user secrets](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-6.0\u0026tabs=windows): Right-click your project name in \"Solution Explorer\", then click \"Manage User Secrets\". This is a good way to keep your API keys secure.)*\n\n#### Program.cs\n```csharp\nserviceCollection.AddOpenAIService();\n```\n\n**OR**\n\n```csharp\nserviceCollection.AddOpenAIService(settings =\u003e { settings.ApiKey = Environment.GetEnvironmentVariable(\"MY_OPEN_AI_API_KEY\"); });\n```\n\nAfter injecting your service, you can retrieve it from the service provider:\n```csharp\nvar openAiService = serviceProvider.GetRequiredService\u003cIOpenAIService\u003e();\n```\n\nYou can set a default model (optional):\n```csharp\nopenAiService.SetDefaultModelId(Models.Gpt_4o);\n```\n\n## Chat GPT Sample\n```csharp\nvar completionResult = await openAiService.ChatCompletion.CreateCompletion(new ChatCompletionCreateRequest\n{\n    Messages = new List\u003cChatMessage\u003e\n    {\n        ChatMessage.FromSystem(\"You are a helpful assistant.\"),\n        ChatMessage.FromUser(\"Who won the world series in 2020?\"),\n        ChatMessage.FromAssistant(\"The Los Angeles Dodgers won the World Series in 2020.\"),\n        ChatMessage.FromUser(\"Where was it played?\")\n    },\n    Model = Models.Gpt_4o,\n});\nif (completionResult.Successful)\n{\n    Console.WriteLine(completionResult.Choices.First().Message.Content);\n}\n```\n\n---\n## Notes\nDue to time constraints, not all methods have been thoroughly tested or fully documented. If you encounter any issues, please report them or submit a pull request. Your contributions are always appreciated.\n\nNeedless to say, I cannot accept responsibility for any damage caused by using the library.\n\n## Changelog\n### 9.0.3\n- Updated `Microsoft.Extensions.AI` to version `9.4.0-preview.1.25207.5`  \n- Added new models to the model list\n\n### 9.0.2  \n- Updated `Microsoft.Extensions.AI` to version `9.3.0-preview.1.25114.11`  \n- Added reasoning effort parameters  \n- Added `o1` and `o3-mini` models to the model list\n\n### 9.0.1\n- Message list now accept RunId\n- Upgraded to Microsoft.Extensions.AI version 9.0.1, which resolves the \"Method not found: '!!0\" error when used alongside other SDKs with different versions.\n\n### 9.0.0\n- .NET 9 support added.\n- ⚠️ Support for .NET 6 and .NET 7 has ended.\n- Fixed utility library issues and synced with latest version.\n\n### 8.10.1\n- Fixed an issue with the `Store` parameter being included in requests by default, causing errors with Azure OpenAI models. The parameter is now optional and excluded from serialization unless explicitly set.\n\n### 8.10.0\n- Added support for `Microsoft.Extensions.AI` `IChatClient` and `IEmbeddingGenerator` (more information will be coming soon to the Wiki).\n- Added missing `Temperature` and `TopP` parameters to `AssistantResponse`.\n- Added missing `Store` parameter to `ChatCompletionCreateRequest`.\n\n- Breaking Changes:\n   - ⚠️ `CreatedAt` parameter renamed to `CreatedAtUnix` and converted to `long` instead of `int`. Added `CreatedAt` parameter as `DateTimeOffset` type, which will automatically convert Unix time to `DateTime`.\n\n### 8.9.0\n- Realtime API implementation is completed. As usual this is the first version and it may contain bugs. Please report any issues you encounter.\n- [Realtime Sample](https://github.com/betalgo/openai/wiki/realtime)\n\n### 8.8.0\n\n- **Compatibility Enhancement**: You can now use this library alongside the official OpenAI library and/or Semantic Kernel within the same project. The name changes in this update support this feature.\n\n- **Namespace and Package ID Update**: The namespace and PackageId have been changed from `Betalgo.OpenAI` to `Betalgo.Ranul.OpenAI`.\n\n- **OpenAI Naming Consistency**: We've standardized the use of \"OpenAI\" throughout the library, replacing any instances of \"OpenAi\" or other variations.\n\n- **Migration Instructions**: Intellisense should assist you in updating your code. If it doesn't, please make the following changes manually:\n  - Switch to the new NuGet package: `Betalgo.Ranul.OpenAI` instead of `Betalgo.OpenAI`.\n  - Update all namespaces from `OpenAI` to `Betalgo.Ranul.OpenAI`.\n  - Replace all occurrences of \"OpenAi\", \"Openai\", or any other variations with \"OpenAI\".\n\n- **Need Help?**: If you encounter any issues, feel free to reach out via our Discord channel, Reddit channel, or GitHub discussions. We're happy to assist.\n\n- **Feedback Welcomed**: If you notice any mistakes or missing name changes, please create an issue to let us know.\n\n- **Utilities Library Status**: Please note that the Utilities library might remain broken for a while. I will focus on fixing it after completing the real-time API implementation.\n\n### [More Change Logs](https://github.com/betalgo/openai/wiki/Change-Logs)\n---\n\nFor any issues, contributions, or feedback, feel free to reach out or submit a pull request.\n\nBetalgo X: [Betalgo (@Betalgo) / X (twitter.com)](https://twitter.com/Betalgo)  \nBetalgo Linkedin:  [Betalgo | LinkedIn](https://www.linkedin.com/company/betalgo-up )  \nTolga X: [Tolga Kayhan (@kayhantolga) / X (twitter.com)](https://twitter.com/kayhantolga)  \nTolga Linkedin: [Tolga Kayhan | LinkedIn](https://www.linkedin.com/in/kayhantolga/)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetalgo%2Fopenai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetalgo%2Fopenai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetalgo%2Fopenai/lists"}