Cisharpai.OpenAi 0.4.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Cisharpai.OpenAi --version 0.4.0
                    
NuGet\Install-Package Cisharpai.OpenAi -Version 0.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cisharpai.OpenAi" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cisharpai.OpenAi" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Cisharpai.OpenAi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cisharpai.OpenAi --version 0.4.0
                    
#r "nuget: Cisharpai.OpenAi, 0.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cisharpai.OpenAi@0.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cisharpai.OpenAi&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=Cisharpai.OpenAi&version=0.4.0
                    
Install as a Cake Tool

Cisharpai.OpenAi

OpenAI provider for the Cisharpai unified LLM client library.

Features

  • Chat completions (GPT-4, GPT-4.1, GPT-4.5)
  • Reasoning models (o1, o3, o4-mini) with configurable reasoning effort
  • Responses API (GPT-5) with status/incomplete handling
  • Text embeddings (text-embedding-3-small, text-embedding-3-large, ada-002)
  • JSON Mode and Structured Outputs (with refusal handling)
  • Tool calling / function calling (all ToolChoice variants)
  • Vision (image file paths and base64)
  • Streaming (token-by-token via SSE)
  • Built-in HTTP resilience (retries, timeouts)

Quick Start

using Cisharpai;
using Cisharpai.Models;
using Cisharpai.OpenAi;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddOpenAiClient(options =>
{
    options.ApiKey = "YOUR_API_KEY";
    options.DefaultModel = OpenAiModels.Chat.Gpt4_1Nano;
});

var provider = services.BuildServiceProvider();
var client = provider.GetRequiredService<IChatCompletionClient>();

var request = new ChatCompletionRequest(
    Messages: [new LlmMessage(LlmRole.User, "Say hello in one sentence.")],
    Temperature: 0.2,
    MaxTokens: 100);

var response = await client.GetChatCompletionAsync(request);
Console.WriteLine(response.Content);

Embeddings

services.AddOpenAiEmbeddingClient(options =>
{
    options.ApiKey = "YOUR_API_KEY";
    options.DefaultModel = OpenAiModels.Embedding.TextEmbedding3Small;
});

var embeddingClient = provider.GetRequiredService<IEmbeddingClient>();
var result = await embeddingClient.GetEmbeddingAsync(
    new EmbeddingRequest(Input: ["Hello world"]));

Available Models

Chat: Gpt4_1, Gpt4_1Mini, Gpt4_1Nano, Gpt4o, Gpt4oMini, Gpt4_5, O3, O3Mini, O3Pro, O4Mini, O1, O1Mini

Embedding: TextEmbedding3Small, TextEmbedding3Large, TextEmbeddingAda002

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Cisharpai.OpenAi:

Package Downloads
Cisharpai.Rag.OpenAi

Bridge package connecting Cisharpai.OpenAi hosted retrieval (file_search) with Cisharpai.Rag's IRetriever contract.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0-alpha.16.404 72 9/27/2026
0.5.0-alpha.12.396 63 9/22/2026
0.5.0-alpha.8.391 64 9/21/2026
0.5.0-alpha.4.386 63 9/21/2026
0.4.0 139 9/20/2026
0.4.0-PullRequest81.41.376 67 9/16/2026
0.4.0-PullRequest81.36.378 61 9/16/2026
0.4.0-PullRequest81.36.377 58 9/16/2026
0.4.0-alpha.35.380 70 9/16/2026
0.4.0-alpha.34.368 67 9/15/2026
0.4.0-alpha.33.358 59 9/15/2026
0.4.0-alpha.32.353 61 9/15/2026
0.4.0-alpha.31.346 65 9/14/2026
0.4.0-alpha.30.340 62 9/14/2026
0.4.0-alpha.29.336 59 9/13/2026
0.4.0-alpha.28.330 65 9/13/2026
0.4.0-alpha.27.324 63 9/13/2026
0.4.0-alpha.26.319 58 9/13/2026
0.4.0-alpha.25.309 61 9/13/2026
0.4.0-alpha.24.306 58 9/13/2026
Loading failed