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
  • Unbound API Key: Generated from your application settings

Installation

Step 1: Install Codex CLI

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

Step 2: Configure Environment Variables

Set up your environment variables to point Codex to your Unbound AI Gateway:
export OPENAI_BASE_URL=https://api.getunbound.ai
export OPENAI_API_KEY=<UNBOUND_API_KEY>
Replace <UNBOUND_API_KEY> with your actual Unbound API key from your application dashboard.

Step 3: 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"

Configuration Options

Environment Variables

You can also set these variables in your shell profile (.bashrc, .zshrc, etc.) for persistent configuration:
# Add to your ~/.bashrc or ~/.zshrc
echo 'export OPENAI_BASE_URL=https://api.getunbound.ai' >> ~/.bashrc
echo 'export OPENAI_API_KEY=<UNBOUND_API_KEY>' >> ~/.bashrc
source ~/.bashrc

Alternative Configuration

You can also configure Codex using a configuration file:
# Create a config file
mkdir -p ~/.config/codex
echo 'OPENAI_BASE_URL=https://api.getunbound.ai' > ~/.config/codex/config
echo 'OPENAI_API_KEY=<UNBOUND_API_KEY>' >> ~/.config/codex/config

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
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