A strongly-typed .NET SDK for the Codex CLI — launch it as a subprocess, stream events, and build integrations with a clean async API.
| Mode | Best for | Docs |
|---|---|---|
codex exec |
Stream JSONL session events from normal Codex runs | Exec docs |
codex app-server |
Deep, event-driven integrations (threads / turns / streaming deltas) | App Server docs |
codex mcp-server |
Using Codex as an MCP tool provider | MCP Server docs |
dotnet add package JKToolKit.CodexSDKPrerequisites: .NET 10+ and Codex CLI on your PATH.
using JKToolKit.CodexSDK;
using JKToolKit.CodexSDK.Models;
await using var sdk = CodexSdk.Create();
// --- Exec mode: stream session events ---
await using var session = await sdk.Exec.StartSessionAsync(
new CodexSessionOptions("<workdir>", "Write a hello world program")
{
Model = CodexModel.Gpt51Codex
});
await foreach (var evt in session.GetEventsAsync())
{
Console.WriteLine(evt);
}
// --- App Server: threads + turns + streaming deltas ---
await using var app = await sdk.AppServer.StartAsync();
// --- MCP Server: tool discovery + invocation ---
await using var mcp = await sdk.McpServer.StartAsync();Full docs, examples, and API reference live in docs/:
- Exec mode — sessions, streaming events, structured outputs, code reviews
- App Server — threads, turns, approvals, DI, resiliency
- MCP Server — tool discovery, sessions, follow-ups
dotnet run --project src/JKToolKit.CodexSDK.Demo -- "Your prompt here"See more demo commands in the full docs.
Contributions welcome — open issues or pull requests for bugs, features, or docs.
