TECHNOLOGY

Choose Codex exec, SDK or app-server for an integration

In this article
THE QUICK TAKE

Choose the integration layer by who owns the work lifecycle and interface, rather than by assuming that every embedding needs the lowest-level protocol.

Codex can be used from a command-line job, a programmatic SDK or a rich client protocol. These are integration choices around the agent, not interchangeable names for a model. Start by describing how work begins, continues and returns an artifact to the surrounding application.

Use exec for a bounded process boundary

A script can invoke Codex for a defined repository question and collect the final artifact. This fits a job that has a clear input and an expected stopping point. The illustrative command below does not prescribe authentication or repository setup; those remain part of the environment in which the process runs.

codex exec "Explain the export path and return the relevant source files"

Use the SDK for application-level orchestration

The official TypeScript SDK exposes a thread and a run operation. An application can keep that thread object or resume a thread when its workflow requires continuity. The following small example illustrates the documented API shape. It is not a complete service implementation or a claim that a returned explanation has been independently validated.

import { Codex } from "@openai/codex-sdk";
const client = new Codex();
const thread = client.startThread();
const result = await thread.run("Explain the export path");
console.log(result.finalResponse);

Use app-server when the client owns interaction

App-server exposes conversation history, authentication flows, approvals and streamed events through a documented client protocol. This is useful when the product needs to render and control the agent lifecycle directly. The client then has more integration work: request correlation, event projection and user-interface state become explicit responsibilities rather than details hidden inside a terminal process.

Compare the ownership boundaries

The layers can serve related tasks with different amounts of surrounding control. A useful comparison names the application behavior that requires a particular layer. This keeps selection tied to an actual workflow instead of an abstract preference for more features.

Integration needStarting layerState the surrounding product still owns
Bounded command-line jobCodex execJob input, artifact storage and downstream acceptance.
Programmatic local workflowCodex SDKApplication records and the decision to continue a thread.
Rich interactive clientCodex app-serverInterface state, product-specific tools and user-facing controls.
Review before a writeThe selected layer plus an application ruleThe exact proposed change and the evidence used for approval.

Keep product records outside the agent abstraction

A support dashboard may associate a Codex thread with a customer issue, but the issue remains an application record with its own permissions and status. The integration layer does not replace that record. Preserve the association, the returned artifact and the application’s acceptance decision. This makes a later migration between exec, SDK and app-server easier to reason about because the business object does not disappear into an opaque conversation.

Documentation and further study

Related engineering guides: Reproducible inference stacks: preserving a GPU pilot’s result; Choose a local AI stack: desktop chat, shared UI or coding agent.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles