Skip to content

Migrate C# library and samples from Betalgo.Ranul.OpenAI to official OpenAI NuGet package #632

@scottaddie

Description

@scottaddie

Summary

The C# library and several samples currently depend on Betalgo.Ranul.OpenAI, a community-maintained OpenAI client library. We should migrate to the official OpenAI NuGet package, which is maintained by OpenAI in collaboration with Microsoft and generated from the OpenAI OpenAPI
specification
.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions