Incursa.OpenAI.Codex
2.3.0
Prefix Reserved
dotnet add package Incursa.OpenAI.Codex --version 2.3.0
NuGet\Install-Package Incursa.OpenAI.Codex -Version 2.3.0
<PackageReference Include="Incursa.OpenAI.Codex" Version="2.3.0" />
<PackageVersion Include="Incursa.OpenAI.Codex" Version="2.3.0" />
<PackageReference Include="Incursa.OpenAI.Codex" />
paket add Incursa.OpenAI.Codex --version 2.3.0
#r "nuget: Incursa.OpenAI.Codex, 2.3.0"
#:package Incursa.OpenAI.Codex@2.3.0
#addin nuget:?package=Incursa.OpenAI.Codex&version=2.3.0
#tool nuget:?package=Incursa.OpenAI.Codex&version=2.3.0
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.
This package is DI-agnostic and exposes the runtime API:
CodexClientCodexThreadCodexTurn- typed options, event, item, result, and exception models such as
CodexClientOptions,CodexPlanModeOptions,CodexThreadOptions,CodexTurnOptions,CodexInputItem,CodexThreadEvent,CodexThreadItem,CodexRunResult,CodexThreadSnapshot,CodexAccountRateLimitsResult,CodexRuntimeCapabilities,CodexRuntimeMetadata, andCodexException
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()beforeInitializeAsync()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 rate-limit reads, and turn steering or interruptionExec(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.
Major API Surfaces
CodexClient: the root entry point for runtime startup, thread management, model discovery, client-wide raw event observation, account rate-limit reads, andIsCodexAvailableAsync()for an executable preflightCodexThread: a stateful conversation handle withRunAsync,RunStreamedAsync,StartTurnAsync,ReadAsync,SetNameAsync,CompactAsync,GetGoalAsync,SetGoalAsync,SetGoalStatusAsync,ClearGoalAsync,RollbackAsync,UnsubscribeAsync,UpdateMetadataAsync, andShellCommandAsyncCodexTurn: a single-turn handle withStreamAsync,StreamNormalizedAsync,ObserveEventsAsync,ObserveNormalizedEventsAsync,RunAsync,RunToResultAsync,SteerAsync, andInterruptAsyncCodexClientOptions: backend selection, executable path override, API key, configuration, plan-mode defaults, environment, and approval handlerCodexThreadOptions,CodexThreadListOptions, andCodexTurnOptions: working directory, thread origin metadata, sandbox, approval, model, Fast mode service tier, output schema, sort, and list-filter settingsCodexInputItemand the typed input union for text, remote image, local image, skill, and mention inputsCodexThreadEvent,CodexThreadItem,CodexRunResult,CodexTurnEvent,CodexTurnResult,CodexThreadGoal,CodexThreadSnapshot,CodexAccountRateLimitsResult,CodexTurnPlanUpdatedEvent,CodexAccountRateLimitsUpdatedEvent,CodexRuntimeCapabilities,CodexRuntimeMetadata, andCodexExceptionfor streamed data, results, and diagnostics.CodexRunResult.FinalResponsestays nullable for commentary-only turns.
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.
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 | Versions 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. |
-
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.