microsoft / microsoft/foundry-local
Migrate C# library and samples from Betalgo.Ranul.OpenAI to official OpenAI NuGet package
- Dominant language
- C++
- Stars
- 2.6k
- Forks
- 369
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 39
Description
## Summary
The C# library and several samples currently depend on [`Betalgo.Ranul.OpenAI`](https://www.nuget.org/packages/Betalgo.Ranul.OpenAI), a community-maintained OpenAI client library. We should migrate to the official [`OpenAI`](https://www.nuget.org/packages/OpenAI) NuGet package, which is maintained by OpenAI in collaboration with Microsoft and generated from the [OpenAI OpenAPI
specification](https://github.com/openai/openai-openapi).
## Motivation
- **Official support**: The `OpenAI` package is maintained by OpenAI and Microsoft, ensuring long-term support, timely updates, and alignment with the OpenAI API.
- **API parity**: Generated from the OpenAPI spec, the official package guarantees accurate coverage of the OpenAI REST API surface.
- **Ecosystem alignment**: As a Microsoft project, Foundry Local should align with the official Microsoft-collaborated library rather than a community alternative.
- **Partial migration already exists**: Two samples (`foundry-local-web-server` and `tool-calling-foundry-local-web-server`) already use the official `OpenAI` package (v2.5.0), demonstrating feasibility.
## Scope
### Library (core dependency)
- `sdk/cs/src/Microsoft.AI.Foundry.Local.csproj` — references `Betalgo.Ranul.OpenAI` v9.1.0
- Source files with Betalgo `using` statements:
- `sdk/cs/src/OpenAI/ChatClient.cs`
- `sdk/cs/src/OpenAI/AudioClient.cs`
- `sdk/cs/src/OpenAI/ChatCompletionRequestResponseTypes.cs`
- `sdk/cs/src/OpenAI/AudioTranscriptionRequestResponseTypes.cs`
- `sdk/cs/src/OpenAI/LiveAudioTranscriptionTypes.cs`
- `sdk/cs/src/OpenAI/ToolCallingExtensions.cs`
- `sdk/cs/src/Detail/JsonSerializationContext.cs`
### Tests
- `sdk/cs/test/FoundryLocal.Tests/ChatCompletionsTests.cs`
### Samples (4 projects via Central Package Management)
- `samples/cs/tutorial-chat-assistant`
- `samples/cs/tutorial-tool-calling`
- `samples/cs/tutorial-voice-to-text`
- `samples/cs/tutorial-document-summarizer`
### Samples (direct Betalgo usage in code)
- `samples/cs/native-chat-completions`
- `samples/cs/model-management-example`
- `samples/cs/tool-calling-foundry-local-sdk`
### Configuration files
- `samples/cs/Directory.Packages.props` — central version `Betalgo.Ranul.OpenAI` v9.2.0
### Documentation
- `sdk/cs/README.md`
- `sdk/cs/docs/api/microsoft.ai.foundry.local.openaiaudioclient.md`
- `sdk/cs/docs/api/microsoft.ai.foundry.local.openaichatclient.md`
## Considerations
- **Breaking change for library consumers**: This is a public API change since the library exposes Betalgo types (e.g., `ChatCompletionCreateRequest`, `ChatCompletionCreateResponse`). Consumers using
these types directly will need to update their code.
- **Type mapping**: The two libraries have different type hierarchies and namespaces. A mapping guide for commonly used types would be helpful.
- **Realtime API**: The library uses Betalgo's `RealtimeModels` for live audio transcription (`LiveAudioTranscriptionTypes.cs`). Verify the official package has equivalent Realtime API support.
- **Version alignment**: The samples already on the official package use v2.5.0. The library should target a stable version.
Contributor guide
Research direction
Start with sdk/cs/src/Microsoft.AI.Foundry.Local.csproj and the listed source files to compare the current Betalgo usage with the official OpenAI package, including its Realtime API support. Run sdk/cs/test/FoundryLocal.Tests/ChatCompletionsTests.cs and review the listed samples, configuration, and documentation. Done means the library, tests, samples, and documentation no longer depend on Betalgo and their public API changes are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100