Skip to main content

Requirements

The Codex TypeScript SDK requires:
  • Node.js 18 or higher
  • The @openai/codex CLI 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
Run the script:

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 your tsconfig.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:
Package Name
string
@openai/codex-sdk
Type
string
ES Module (.js files with import/export)
Main Export
string
./dist/index.js
Type Definitions
string
./dist/index.d.ts
License
string
Apache-2.0

Troubleshooting

Ensure you’ve installed the package and that your node_modules is up to date:
The SDK requires the codex CLI to be installed. Install it globally:
Or specify a custom path when creating the client:
Verify you’re using Node.js 18 or higher:
Upgrade if needed using nvm or download from nodejs.org.

Next Steps

Usage Guide

Learn how to use the SDK with code examples and detailed API documentation