Skip to main content
Codex is a powerful command-line interface (CLI) tool that provides AI-powered coding assistance directly from your terminal. It offers intelligent code suggestions, explanations, and debugging help to enhance your development workflow. By integrating Codex with Unbound Security AI Gateway, you can leverage these AI capabilities while maintaining enterprise-grade security, cost control, and compliance.

Prerequisites

Before setting up the integration, ensure you have:
  • Node.js: Version 20 or higher installed on your system
  • Unbound Application: A configured application in your Unbound Security dashboard

Installation

Step 1: Install Codex CLI

Install the Codex CLI globally using npm:
npm install -g @openai/codex

Step 2: Configure Environment Variables

To set up Codex to point to Unbound AI Gateway, just run the following command in the terminal:
python3 <(curl -fsSl https://raw.githubusercontent.com/websentry-ai/setup/refs/heads/main/codex/gateway/setup.py) --domain gateway.getunbound.ai
If your Unbound Gateway URL changes, you can update it in the command above by replacing gateway.getunbound.ai Once the script starts, it will generate a login URL. Click the URL or open it in your browser. The page will automatically:
  • Authenticate your account through the Unbound dashboard.
  • Retrieve and register your gateway credentials.
  • Redirect you back to a success page.
You can close the browser window once the callback is complete. Return to your terminal. The installation will finish automatically.

Step 3: First-Time Setup

When you open Codex for the first time after setup, you’ll be presented with two options:
  1. Sign in with ChatGPT
  2. Provide your own API Key
Select (Provide your own API Key). The API key will be automatically filled in. Simply press Enter to proceed. Codex will then be ready to use.

Step 4: Verify Installation

Test that Codex is properly configured:
codex --version

Usage

Basic Usage

Once configured, you can start using Codex in your terminal:
codex
This launches the interactive Codex interface where you can:
  • Ask coding questions
  • Get code suggestions
  • Request explanations for existing code
  • Debug issues with AI assistance

Example Commands

# Start interactive mode
codex

# Ask a specific question
codex "How do I create a REST API in Node.js?"

# Get help with debugging
codex "Help me debug this Python function"

Troubleshooting

Common Issues

Codex not found after installation:
# Check if npm global bin is in your PATH
npm config get prefix
# Add to PATH if needed
export PATH="$(npm config get prefix)/bin:$PATH"
API key not recognized:
# Verify your environment variables
echo $OPENAI_API_KEY
echo $OPENAI_BASE_URL
# Once the setup is complete, open codex in a new terminal
Connection issues:
  • Ensure your Unbound API key is valid
  • Check that the base URL is correct
  • Verify your internet connection

Security Benefits

Using Codex with Unbound Security AI Gateway provides:
  • Request Monitoring: All AI requests are logged and monitored
  • Cost Control: Set spending limits and track usage
  • Compliance: Ensure AI interactions meet your organization’s standards
  • Guardrails: Apply security policies to AI responses
  • Audit Trail: Complete visibility into AI usage patterns