Incursa.OpenAI.Codex 2.5.0

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

Incursa.OpenAI.Codex

Async-only Codex runtime for .NET. It wraps the local codex executable and starts it as a subprocess, so the machine running your app must already have Codex installed and authenticated. Any ApiKey or BaseUrl settings are forwarded to that subprocess; they do not replace the local Codex installation requirement.

Installation and prerequisites

The package targets .NET 10 (net10.0). Install it into an application that already has the matching local Codex CLI and an authenticated Codex account:

dotnet add package Incursa.OpenAI.Codex

The SDK starts codex locally. Install and authenticate the CLI separately, or set CodexClientOptions.CodexPathOverride when the executable is not on PATH. ApiKey and BaseUrl are passed to the local process; they do not turn this package into a direct hosted API client. Call IsCodexAvailableAsync() for a no-throw executable check before initialization.

This package is DI-agnostic and exposes the runtime API:

When To Use This Package

Use this package when you want a .NET wrapper around the local Codex CLI for prompt/response flows, stateful threads, or turn-level control.

  • Use the OpenAI SDK when you want direct API access from .NET.
  • Use ChatKit when you want a hosted chat UI surface.
  • Use the Agents SDK when you want higher-level agent orchestration.
  • Use this package when you specifically want Codex-backed workflows driven from a local Codex install.
  • If you want a no-throw preflight for the local executable, call await client.IsCodexAvailableAsync() before InitializeAsync() or any turn operation.

Hello World

The smallest useful call starts a thread, sends one prompt, and prints the final response:

using Incursa.OpenAI.Codex;

await using var client = new CodexClient();

CodexThread thread = await client.StartThreadAsync(new CodexThreadOptions
{
    SkipGitRepoCheck = true,
});

CodexRunResult result = await thread.RunAsync("Say hello from Codex in one sentence.");
Console.WriteLine(result.FinalResponse);

CodexRunResult.FinalResponse can be null when a turn completes with commentary only and never produces a final-answer or phase-less assistant message.

CodexClient is async-only. Dispose it with await using.

If you need DI registration, use Incursa.OpenAI.Codex.Extensions and call AddCodex(...).

Backend Modes

The API supports both backend modes:

  • AppServer (codex app-server --listen stdio://) for the full JSON-RPC surface, thread lifecycle operations, thread goals, model listing, account login/read/logout, account rate-limit reads, and turn steering or interruption
  • Exec (codex exec --experimental-json) for the CLI-backed run and stream flow

Use AppServer when you need long-lived conversations, CodexThread management, or turn control. Use Exec when you only need prompt-in, response-out behavior.

The app-server v2 thread-start request uses the current wire shapes: a simple approval mode is a string such as "on-request", and a granular policy uses snake_case keys such as mcp_elicitations and request_permissions. Thread sandbox access is expressed as "read-only", "workspace-write", or "danger-full-access". Workspace network access, additional directories, and writable roots are carried through the config.sandbox_workspace_write configuration object. External sandbox policies remain turn-level only. Use CodexTurnOptions.SandboxPolicy when a turn needs the richer legacy policy shape.

For new app-server integrations, prefer Never, OnRequest, or Untrusted through CodexApprovalModePolicy. OnFailure remains in the public enum for source compatibility, but current app-server v2 rejects it. The exec backend can pass on-failure through its CLI configuration when the installed Codex runtime accepts that value.

Major API Surfaces

Use CodexClient.ObserveEventsAsync() as the exhaustive raw event channel across the client. Use CodexTurn.StreamNormalizedAsync(), CodexTurn.ObserveNormalizedEventsAsync(), or CodexTurn.RunToResultAsync() for UI clients that must distinguish Codex completion from transport or delivery behavior. CodexTurn.ObserveEventsAsync() and CodexTurn.ObserveNormalizedEventsAsync() expose turn-scoped observable streams that fan out from one underlying Codex reader and replay observed events to later subscribers. Consumers can add System.Reactive in their own app when they want Rx operators over these IObservable<T> surfaces; the core package stays dependency-free. The detailed result exposes TerminalEventSeen, TerminalEventType, TerminalState, FinalResponseText, FinalResponseSource, and assistant output character counts so callers do not need to infer completion from silence.

External messages and current option coverage

Use CodexExternalMessageInput when relaying content from another tool or application. It keeps the tool name, namespace, and content as an explicit external-message item rather than flattening that content into a user prompt:

CodexRunResult result = await thread.RunAsync(
    [new CodexExternalMessageInput
    {
        ToolName = "work-tracker",
        Namespace = "incursa",
        Content = "Ticket INC-42 is ready for review.",
    }]);

CodexConfigObject supports nested configuration values and serializes them to the CLI's dotted config overrides. Use CodexClientOptions.RawConfigOverrides for raw CLI overrides. CodexReasoningEffort.Max, Ultra, and Persistent, per-thread ServiceTier, CodexTurnOptions.ServiceTierForTurn, TurnTrigger, CyberAccessProgram, CodexThreadListOptions.SectionId, and CodexThreadOptions.IncludeTurns are available. The parity review records current differences from the upstream Python and TypeScript packages in quality/upstream-parity-gaps.md.

For the exec backend, configuration is applied in this order: client structured config, client raw overrides, thread structured config, then typed options. Later values win when they address the same key. Raw overrides are passed as literal CLI --config values after structured client configuration. The remaining limitation is the breadth of the generated low-level schema; personality fields are retained as compatibility metadata and should not be used to select model tone.

Features introduced by newer Codex runtimes are checked against the app-server version when the SDK receives runtime metadata. Set CodexClientOptions.RequireCompatibleRuntime to true to turn an unknown or older runtime into an exception; when it is false, inspect CodexClient.RuntimeCompatibilityDiagnostic after a request that uses a gated feature.

Sample

The runnable sample under samples/Incursa.OpenAI.Codex.Sample shows quickstart, streaming, structured output, image input, error handling, and turn controls.

License

Apache 2.0. See the repository root LICENSE.

Product Compatible and additional computed target framework versions.
.NET 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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Incursa.OpenAI.Codex:

Package Downloads
Incursa.OpenAI.Codex.Extensions

Optional dependency-injection and host integration extensions for Incursa.OpenAI.Codex, including IServiceCollection registration and configuration binding.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.5.0 203 10/3/2026
2.4.0 328 7/4/2026
2.3.0 929 5/25/2026
2.2.0 136 5/25/2026
2.1.0 310 5/23/2026
2.0.0 167 5/13/2026
1.3.0 229 5/12/2026
1.2.2 546 5/10/2026
1.2.1 245 5/10/2026
1.2.0 143 5/10/2026
1.1.0 819 5/6/2026
1.0.20 235 4/22/2026
1.0.19 137 4/16/2026
1.0.18 277 3/25/2026
1.0.17 130 3/24/2026