codex-sdk-rest
v1.0.5
Published
Express server proxying OpenAI Codex SDK for agent streaming
Maintainers
Readme
Codex SDK REST
____ ___ ____ _______ __ _ ___ ____ _ _
/ ___/ _ \| _ \| ____\ \/ / | | / _ \ / ___| / \ | |
| | | | | | | | | _| \ / | | | | | | | / _ \ | |
| |__| |_| | |_| | |___ / \ | |__| |_| | |___ / ___ \| |___
\____\___/|____/|_____/_/\_\ |_____\___/ \____/_/ \_\_____|
| _ \| _ \ / _ \ \ / /_ _| _ \| ____| _ \
| |_) | |_) | | | \ \ / / | || | | | _| | |_) |
| __/| _ <| |_| |\ V / | || |_| | |___| _ <
|_| |_| \_\\___/ \_/ |___|____/|_____|_| \_\ Overview
A lightweight Express server that proxies OpenAI agent streaming responses using the Codex SDK. It provides an OpenAI Chat Completions API-compatible interface (/v1/chat/completions).
Features
- OpenAI Compatible API: Supports standard Chat Completions API request/response format.
- Streaming Support: Real-time Server-Sent Events (SSE) for token-by-token responses (
stream=true).
Architecture Note: Thread Reuse & Context Leaks
To mitigate the significant initialization latency of the Codex SDK, this server adopts a thread reuse strategy.
Known Limitation: This architecture interacts with the Codex CLI's internal context manager. Consequently, context leaks may occur between requests or when integrated with other context-aware systems, as the context state is persisted to ensure performance. This is a known and unavoidable trade-off in the current implementation.
Configuration
- Thread Options:
approvalPolicy: 'never'sandboxMode: 'read-only'networkAccessEnabled: falsewebSearchEnabled: falsemodelReasoningEffort: 'high'model: 'GPT-5.1-Codex-Mini'
Usage
run
npx codex-sdk-restAPI Endpoints
GET /init
Initializes a test Codex thread (mostly for internal testing).
- Note: Does not return a response body.
POST /v1/chat/completions
Send a chat message to the agent.
Actually work Parameters (JSON Body):
messages(array): List of messages (e.g.,[{ "role": "user", "content": "Hello" }]).stream(boolean): Iftrue, streams partial results via SSE.
