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
<PackageReference Include="JD.SemanticKernel.Connectors.OpenAICodex" Version="0.1.3" />
<PackageVersion Include="JD.SemanticKernel.Connectors.OpenAICodex" Version="0.1.3" />
<PackageReference Include="JD.SemanticKernel.Connectors.OpenAICodex" />
paket add JD.SemanticKernel.Connectors.OpenAICodex --version 0.1.3
#r "nuget: JD.SemanticKernel.Connectors.OpenAICodex, 0.1.3"
#:package JD.SemanticKernel.Connectors.OpenAICodex@0.1.3
#addin nuget:?package=JD.SemanticKernel.Connectors.OpenAICodex&version=0.1.3
#tool nuget:?package=JD.SemanticKernel.Connectors.OpenAICodex&version=0.1.3
JD.SemanticKernel.Connectors.OpenAICodex
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_KEY→CODEX_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 loginequivalent for .NET applications - Semantic Kernel integration — One-call
UseCodexChatCompletion()extension method - DI support —
AddCodexAuthentication()for dependency injection - Model discovery —
IModelDiscoveryProviderwith known Codex models (o3, o4-mini, codex-mini, GPT-4.1, etc.) - Multi-TFM — Targets
netstandard2.0,net8.0, andnet10.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 |
Related Packages
- JD.SemanticKernel.Connectors.ClaudeCode — Claude Code connector
- JD.SemanticKernel.Connectors.GitHubCopilot — GitHub Copilot connector
- JD.SemanticKernel.Connectors.Abstractions — Shared abstractions
License
| Product | Versions 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. |
-
.NETStandard 2.0
- JD.SemanticKernel.Connectors.Abstractions (>= 0.1.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
- System.Text.Json (>= 10.0.3)
-
net10.0
- JD.SemanticKernel.Connectors.Abstractions (>= 0.1.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
- Microsoft.SemanticKernel (>= 1.72.0)
- Microsoft.SemanticKernel.Connectors.OpenAI (>= 1.72.0)
-
net8.0
- JD.SemanticKernel.Connectors.Abstractions (>= 0.1.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
- Microsoft.SemanticKernel (>= 1.72.0)
- Microsoft.SemanticKernel.Connectors.OpenAI (>= 1.72.0)
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.