JD.SemanticKernel.Connectors.OpenAICodex 0.1.3

dotnet add package JD.SemanticKernel.Connectors.OpenAICodex --version 0.1.3
                    
NuGet\Install-Package JD.SemanticKernel.Connectors.OpenAICodex -Version 0.1.3
                    
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="JD.SemanticKernel.Connectors.OpenAICodex" Version="0.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JD.SemanticKernel.Connectors.OpenAICodex" Version="0.1.3" />
                    
Directory.Packages.props
<PackageReference Include="JD.SemanticKernel.Connectors.OpenAICodex" />
                    
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 JD.SemanticKernel.Connectors.OpenAICodex --version 0.1.3
                    
#r "nuget: JD.SemanticKernel.Connectors.OpenAICodex, 0.1.3"
                    
#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 JD.SemanticKernel.Connectors.OpenAICodex@0.1.3
                    
#: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=JD.SemanticKernel.Connectors.OpenAICodex&version=0.1.3
                    
Install as a Cake Addin
#tool nuget:?package=JD.SemanticKernel.Connectors.OpenAICodex&version=0.1.3
                    
Install as a Cake Tool

JD.SemanticKernel.Connectors.OpenAICodex

NuGet CI License: MIT

OpenAI Codex session connector for Semantic Kernel. Provides UseCodexChatCompletion() to wire local Codex CLI OAuth credentials (or an explicit API key) into any Semantic Kernel application without managing tokens manually.

Features

  • Multi-source credential resolution — Options → OPENAI_API_KEYCODEX_TOKEN~/.codex/auth.json → interactive device code login
  • Token exchange — Automatically exchanges Codex OAuth tokens for OpenAI API keys via the standard token exchange endpoint
  • Token refresh — Automatically refreshes expired tokens using stored refresh tokens
  • Device code login — Full interactive codex login equivalent for .NET applications
  • Semantic Kernel integration — One-call UseCodexChatCompletion() extension method
  • DI supportAddCodexAuthentication() for dependency injection
  • Model discoveryIModelDiscoveryProvider with known Codex models (o3, o4-mini, codex-mini, GPT-4.1, etc.)
  • Multi-TFM — Targets netstandard2.0, net8.0, and net10.0

Installation

dotnet add package JD.SemanticKernel.Connectors.OpenAICodex

Quick Start

Minimal (auto-discovers credentials)

using JD.SemanticKernel.Connectors.OpenAICodex;
using Microsoft.SemanticKernel;

var kernel = Kernel.CreateBuilder()
    .UseCodexChatCompletion()
    .Build();

With explicit API key

var kernel = Kernel.CreateBuilder()
    .UseCodexChatCompletion(apiKey: "sk-your-openai-api-key")
    .Build();

With specific model

var kernel = Kernel.CreateBuilder()
    .UseCodexChatCompletion(CodexModels.O3)
    .Build();

Using Dependency Injection

services.AddCodexAuthentication(o => o.ApiKey = "sk-...");

// Or from configuration:
services.AddCodexAuthentication(configuration);
// Reads from "CodexSession" section in appsettings.json

Direct HttpClient usage

using var client = CodexHttpClientFactory.Create();
// Use with any OpenAI-compatible API

Credential Resolution Order

The provider checks these sources in order and uses the first valid credential found:

Priority Source Description
1 CodexSessionOptions.ApiKey Explicit API key from options/config
2 CodexSessionOptions.AccessToken Explicit OAuth token from options/config
3 OPENAI_API_KEY env var Standard OpenAI environment variable
4 CODEX_TOKEN env var Codex-specific environment variable
5 ~/.codex/auth.json Codex CLI local credentials file
6 Device code login Interactive OAuth (when EnableInteractiveLogin = true)

Configuration

appsettings.json

{
  "CodexSession": {
    "ApiKey": null,
    "Issuer": "https://auth.openai.com",
    "ApiBaseUrl": "https://api.openai.com/v1",
    "AutoRefreshTokens": true,
    "EnableInteractiveLogin": false
  }
}

Available Options

Option Type Default Description
ApiKey string? null Explicit OpenAI API key
AccessToken string? null Explicit OAuth access token
CredentialsPath string? null Custom path to auth.json
Issuer string https://auth.openai.com OAuth issuer URL
ApiBaseUrl string https://api.openai.com/v1 OpenAI API base URL
ClientId string? null OAuth client ID for device code flow
EnableInteractiveLogin bool false Enable interactive device code login
AutoRefreshTokens bool true Auto-refresh expired tokens

Available Models

Constant Model ID Description
CodexModels.O3 o3 Most capable reasoning model
CodexModels.O4Mini o4-mini Fast, cost-effective reasoning
CodexModels.CodexMini codex-mini-latest Optimised for code generation
CodexModels.Gpt4Point1 gpt-4.1 High-capability general model
CodexModels.Gpt4Point1Mini gpt-4.1-mini Fast general model
CodexModels.Gpt4Point1Nano gpt-4.1-nano Fastest, most cost-effective

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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 JD.SemanticKernel.Connectors.OpenAICodex:

Package Downloads
JD.AI.Core

Core library for JD.AI — agents, providers, sessions, tools, orchestration, and event bus. Shared by the TUI, Gateway, and channel adapters.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.3 964 3/4/2026
0.1.2 648 3/3/2026