Requirements
The Codex TypeScript SDK requires:- Node.js 18 or higher
- The
@openai/codexCLI installed and available in your PATH
Install the SDK
Install the SDK using your preferred package manager:Verify Installation
Create a simple test script to verify the SDK is installed correctly:test.ts
Environment Setup
API Configuration
The SDK requires access to the Codex API. Configure your credentials:1
Set API Key
Set your OpenAI API key as an environment variable:
2
Configure Base URL (Optional)
If you’re using a custom API endpoint, set the base URL:
3
Pass Credentials Programmatically
Alternatively, pass credentials directly when creating the client:
TypeScript Configuration
Ensure yourtsconfig.json is configured for ES modules:
tsconfig.json
The SDK uses ES module syntax (
import/export). Ensure your project is configured to support ES modules.Package Information
The SDK is published as@openai/codex-sdk with the following characteristics:
string
@openai/codex-sdkstring
ES Module (
.js files with import/export)string
./dist/index.jsstring
./dist/index.d.tsstring
Apache-2.0
Troubleshooting
Module Not Found Error
Module Not Found Error
Ensure you’ve installed the package and that your
node_modules is up to date:Codex CLI Not Found
Codex CLI Not Found
The SDK requires the Or specify a custom path when creating the client:
codex CLI to be installed. Install it globally:Node.js Version Error
Node.js Version Error
Next Steps
Usage Guide
Learn how to use the SDK with code examples and detailed API documentation